コードの内容は、入力された文字列の文字数と"th"または"Th"の出現回数、加えてそれらを"+"に置き換えます。
関数judの実行で止まるので、関数judが間違っているのだと思うのですが、解明できませんでした。知恵をお貸しください。
c言語
1#include <stdio.h> 2 3int jud(char *se); 4 5int main(void){ 6 int num=0; 7 int i=0; 8 int count; 9 char s[256]; 10 char c; 11 puts("英文を入力して下さい."); 12 c=getchar(); 13 while(c!=EOF){ 14 //putchar(c); 15 s[i]=c; 16 i+=1; 17 if(c!='\n'){ 18 num+=1; 19 } 20 c=getchar(); 21 } 22 //puts("1"); 23 //printf("%s\n",s); 24 25 count=jud(s);//ここから何も出力されなくなります。 26 //puts("2"); 27 printf("%s\n",s); 28 printf("文字数:%d\n",num); 29 printf("th の出現回数:%d\n",count); 30 31 return 0; 32} 33 34int jud(char *se){ 35 int i=0; 36 int count=0; 37 while(se[i]!='\0'){ 38if(se[i]=='t' || se[i]=='T'){ 39 if(se[i+1]=='h' ){ 40 count+=1; 41 se[i]='+'; 42 se[i+1]='+'; 43 } 44 } 45 } 46 return count; 47}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/24 03:17