#include<stdio.h> int main(void) { int digit,space,enter,letter,other; char ch; int i; digit=space=enter=letter=other=0; printf("Enter 15 characters:"); for(i=1;i<=15;i++){ ch=getchar(); if((ch>='a'&&<='z')||(ch>='A'&&<='Z')) letter++; else if(ch>='0'&&ch<='9') digit++; else if(ch=' ') space++; else if(ch=' ') enter++; else other++; } printf("letter=%d,space=%d,enter=%d,digit=%d,other=%d\n",letter,space,enter,digit,other); return 0; }
转载于:https://www.cnblogs.com/jlg0322/p/3379795.html