#include <stdio.h> int main(void) { char ch; int blank, digit, i, letter, other; blank = digit = letter = other = 0; printf("Enter 15characters:"); for(i = 1; i <= 15; i++){ ch = getchar(); if ((ch >= 'a' && ch<= 'z' )||(ch >= 'A' && ch <= 'Z')) letter ++; else if (ch == 32)//32是空格的十进制代号 blank ++; else if ((ch >= '0') &&(ch<= '9'))/字符的代号 digit ++; else other ++; } printf("letter = %d, blank = %d, digit = %d, other = %d\n", letter, blank, digit, other); return 0; }
转载于:https://www.cnblogs.com/chengruiqiking/p/3385455.html