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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit KumarRank #459 · 5.4K reputationPosted Apr 19, 2016, 9:37 PM EDT
Saber ShaikhRank #1,686 · 905 reputationPosted Apr 19, 2016, 9:50 PM EDT
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;