#include版本二:无多重标签,要用到toupper()函数int main(void) { int a_ct, e_ct, i_ct, o_ct, u_ct ; a_ct = e_ct = i_ct = o_ct = u_ct = 0; char ch; printf("Enter some text,enter # to quit.n"); while ((ch = getchar()) != '#') { switch (ch) { case 'a': case 'A': a_ct++; break; case 'e': case 'E': e_ct++; break; case 'i': case 'I': i_ct++; break; case 'o': case 'O': o_ct++; break; case 'u': case'U': u_ct++; break; default: break; } } printf("Number of vowles:A E I O Un"); printf(" %4d%4d%4d%4d%4dn", a_ct, e_ct, i_ct, o_ct, u_ct); return 0; }
#include//toupper()函数的库函数 #include int main(void) { int a_ct, e_ct, i_ct, o_ct, u_ct ; a_ct = e_ct = i_ct = o_ct = u_ct = 0; char ch; printf("Enter some text,enter # to quit.n"); while ((ch = getchar()) != '#') { ch = toupper(ch); switch (ch) { case 'A': a_ct++; break; case 'E': e_ct++; break; case 'I': i_ct++; break; case 'O': o_ct++; break; case'U': u_ct++; break; default: break; } } printf("Number of vowles:A E I O Un"); printf(" %4d%4d%4d%4d%4dn", a_ct, e_ct, i_ct, o_ct, u_ct); return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)