HI Frnds,
write a program for like
J 1
A 1
B 1
A 2
L 1
P 1
U 1
R 1
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Saber ShaikhPosted Apr 20, 2016, 1:50 AM
Count(null,null);//call
{
string test = "JABALPUR";
List
char[] chrs = test.ToCharArray();
string test1 = "JABALPUR";
for (int chrsCount = 1; chrsCount < chrs.Length+1; chrsCount++)
{
test1 = test.Substring(0, chrsCount);
for (int i = 0; i < chrsCount; i++)
{
var s = chrs[i] + " " + Occurence(test1, chrs[i]);
if (str.IndexOf(s) == -1)
{
str.Add(s);
}
}
}
label1.Text = string.Join("\n", str);
}
private int Occurence(string text, char chr)
{
int i = 0, count = 0;
while ((i = text.IndexOf(chr, i)) != -1)
{
count++;
i++;
}
return count;
Amit KumarPosted Apr 20, 2016, 1:37 AM