作者在 2011-05-13 12:40:18 发布以下内容
#include<stdio.h>
void main()
{ printf("input a sentence \n");
char a[80],*p;
int i=0,lowercase=0,uppercase=0,space=0,tab=0,enter=0;
printf("ps: input ctrl+z to end of the input and press enter to show the result\n");
printf("=====================================\n");
while(1)
{ if((a[i]=getchar())==EOF)
break;
i++;
}
p=&a[0];
while(1)
{if(*p==EOF)
break;
if((*p>='a')&&(*p<='z'))
lowercase++;
else if(*p==' ')
space++;
else if(*p==' ')
tab++;
else if(*p=='\n')
enter++;
else if((*p>='A')&&(*p<='Z'))
uppercase++;
p++;
}
printf("=====================================\n");
printf("lowercase %d\n",lowercase);
printf("uppercase %d\n",uppercase);
printf("space %d\n",space);
printf("tab %d\n",tab);
printf("enter %d\n",enter);
}
void main()
{ printf("input a sentence \n");
char a[80],*p;
int i=0,lowercase=0,uppercase=0,space=0,tab=0,enter=0;
printf("ps: input ctrl+z to end of the input and press enter to show the result\n");
printf("=====================================\n");
while(1)
{ if((a[i]=getchar())==EOF)
break;
i++;
}
p=&a[0];
while(1)
{if(*p==EOF)
break;
if((*p>='a')&&(*p<='z'))
lowercase++;
else if(*p==' ')
space++;
else if(*p==' ')
tab++;
else if(*p=='\n')
enter++;
else if((*p>='A')&&(*p<='Z'))
uppercase++;
p++;
}
printf("=====================================\n");
printf("lowercase %d\n",lowercase);
printf("uppercase %d\n",uppercase);
printf("space %d\n",space);
printf("tab %d\n",tab);
printf("enter %d\n",enter);
}