using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace reoccuringletterstring
{
class Program
{
static bool checkString(string str,int len)
{
int i;
bool flag=true;
for(i=len-2;i>=0;i--)
{
if (str[i] == str[len - 1])
flag = false;
}
if(len!=0)
checkString(str,len-1);
return flag;
}
static void Main(string[] args)
{
string str1="true";
string str2 = "foo";
string str3 = "tofol";
//bool val=checkString(str1,str1.Length);
//val=checkString(str2,str2.Length);
bool val=checkString(str3,str3.Length);
}
}
}
This is program to check for reoccurrence of a character in a string
But the call stack is returning value of last pop call
I want to use value of 1st pop
is there any way to break in between call stack
theLizardPosted Jul 3, 2010, 9:04 PM
{
string c;
int x;
}
chrCount[] charArray = new chrCount[0];
Array.Resize(ref charArray, str.Length();
for(int i = 0; i < str.Length(); i++)
{
charArray[i].c = str[i];
charArray[i].x = 0;
}
for (int x = 0; x < str.Length(); x ++)
{
for(int y = 0; y < charArray.Length(); y++)
{
if(charArray[y].c == str[i])
{
charArray[y].x += 1;
}
}
}
does this help?
Sam HobbsPosted Jul 3, 2010, 4:47 PM