2018/5/14程式作業 第3題 for 四子一丙
#include #include int main(void) { char word[50]; int a = 0, b = 0, c = 0, d = 0; scanf("%[A-Za-z0-9 #]", &word); for(int i = 0; word[i] != 35 ;i++) { if(word[i] >= 97 && word[i] <= 122) a++; else if(word[i] >= 65 && word[i] <= 90) b++; else if(word[i] >= 48 && word[i] <= 57) c++; else if(word[i] == 32) d++; } printf("小寫字母出現%d次\n大寫字母出現%d次\n數字出現%d次\n空白出現%d次\n", a, b, c, d); system("pause"); return(0); }
留言
張貼留言