Skip to content

Instantly share code, notes, and snippets.

@ajuanhuang
Created December 5, 2012 13:11
Show Gist options
  • Save ajuanhuang/4215403 to your computer and use it in GitHub Desktop.
Save ajuanhuang/4215403 to your computer and use it in GitHub Desktop.
字符个数
#include<stdio.h>
#include<string.h>
int main()
{
char a[100000];
int f=0,i,c,j=0,k=0,h=0;
while(gets(a))
{
c=strlen(a);
for(i=0;i<c;i++)
{
if(a[i]==' ')
{
f++;
}
else if(a[i]<='9'&&a[i]>='0')
h++;
else if((a[i]<='z'&&a[i]>='a')||(a[i]<='Z'&&a[i]>='A'))
j++;
else
k++;
}printf("%d %d %d %d\n",j,h,f,k);
f=0;j=0;k=0;h=0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment