供参考:
//第3题
#include<stdio.h>
#include<ctype.h>
int main()
{
int i=0,alp=0,dig=0,spc=0,other=0;
char s[80];
gets(s);
while (s[i]){
if(isalpha(s[i])) alp++;//英文字母
else if(isdigit(s[i])) dig++;//数字
else if(isspace(s[i])) spc++;//空格
else other++;//其他
i++;
}
printf("alpha=%d,digit=%d,space=%d,other=%d\n",alp,dig,spc,other);
return 0;
}
//第4题
#include<stdio.h>
int main()
{
int i,j,n=5;
char ch = 'A';
//scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
printf(j>=(n-i-1)?"%c%c":"%c",'*',ch);
printf("\n");
ch++;
}
return 0;
}