need help to show most repeated character

#include "stdafx.h"
#include <conio.h>
#include <stdio.h>
#include <string.h>
void main()
{
for (int i=0;i<strlen(nt);i++)
Tab[i]=int(nt[i]);
for (int i=0;i<strlen(nt)-1;i++)
{
for (int j=i+1;j<strlen(nt);j++)
{
if (Tab[j]>Tab[i])
{
a=Tab[i];
Tab[i]=Tab[j];
Tab[j]=a;
}
}
}
for (int i=0;i<strlen(nt);i++)
{
printf ("Tab[%d]=%d\t",i,Tab[i]);
if (Tab[i]==Tab[0])
{
b++;
F=1;
}
else
{
if (Tab[i]==Tab[p])
{
c++;
if (c==b)
{
b=c;
d=Tab[i];
}
if (c>b)
{
b=c;
d=Tab[i];
F=0;
}
}
else
{
p=i;
c=1;
}
}
}
getch();
}
the user has to enter a sentence that contains at least 3 dashes, cut the sentence between the first and the second dash and shows the most repeated character in this sentence.
i used a do while and cut the sentence successfully, but my problem is when i found 2 most repeated characters. For example 5 'f' and 5 'd'. the program gives me the letter with the least ASCII code, it gives me 'd'. And please, stick to the language i am using because i am not that advanced.
Last edited on
Your code is invalid and shall not be compiled. Try to write at first such a code that at least is compiled without errors.
i ran my program on visual studio, it worked normally without any errors. But the problem is when i face 2 or more repeated characters.
i ran my program on visual studio, it worked normally without any errors. But the problem is when i face 2 or more repeated characters.


The code, as listed, will not compile. Your variables are not declared. How about a clearer explanation of what the program is supposed to do?
Topic archived. No new replies allowed.