#include <stdio.h> void main() { char c; int letter=0,space=0,number=0,other=0; while ((c=getchar())!='\n') { if (65<=c<=90||97<=c<=122)//为什么无论输入什么字符,都会加到letter上!? letter++; else if(c=' ') space++; else if(48<=c<=57) number++; else other++; } printf("%d\n%d\n%d\n%d\n",letter,space,number,other); }
建议重新去看一遍逻辑运算符执行顺序 ...