arkadaşlar bir metinde en çok tekrar eden karakteri nasıl bulabilirim. ve bunu basit şekilde yazmam lazım. yazdığım fonksiyonlarda düzenlemeler yapıcam ama 2.fonsiyonu tamamlayamadım yardımcı olursanız sevinirim.
#include<stdio.h> #include<conio.h>
int numberofwords(char text_1[200]) { int i,sayac;
sayac=1;
for(i=0;text_1!='\0';i++) {
if(text_1==' ')
sayac++; }
printf("number of words in text = %d\n",sayac); return 0; }
int mostrepeatedchar(char text_2[200]) { int array[255] = {'0'}; int i,max,index;
#include<stdio.h>
#include<conio.h>
int numberofwords(char text_1[200])
{
int i,sayac;
sayac=1;
for(i=0;text_1!='\0';i++)
{
if(text_1==' ')
sayac++;
}
printf("number of words in text = %d\n",sayac);
return 0;
}
int mostrepeatedchar(char text_2[200])
{
int array[255] = {'0'};
int i,max,index;
for(i=0;text_2!='\0';i++)
{
++array[text_2];
}
max=array[0];
index = 0;
for(i=0;text_2!='\0';i++)
{
if(array>max)
{
max=array;
index=i;
}
}
printf("the max char is : %c \n",(char)index);
return 0;
}
int main(void)
{
char text[200];
int secilecek_fonksiyon;
printf("What do you want from me?\n\n");
printf("Please enter '1' for calculating number of words in text;\n");
printf("Please enter '2' for most repeated word character in text;\n");
printf("Please enter '3' for probability of most repeated word character in text;\n");
printf("Please enter '4' for probability of any word character in text;\n");
printf("Please enter '5' for length of longest word in text;\n");
printf("Please enter '6' for probability of most repeated word in text;\n");
printf("Please enter '7' for any word in text;\n");
printf("Please enter '0' for exit the program;\n\n");
printf("Please enter any text, later please press 'enter' for continue.\n==>");
gets(text);
printf("Your choice of process =>");
scanf("\n%d",&secilecek_fonksiyon);
if(secilecek_fonksiyon==1)
{
numberofwords(text);
}
return 0;
if(secilecek_fonksiyon==2)
{
mostrepeatedchar(text);
}
return 0;
}