|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 oahzuw 于 2013-8-6 21:06 编辑
如题
没什么新意!实际上参考了小甲鱼老师的
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- int c, others = 0, a[10] = {0};
- int k1, k2, k3;
- k1=k2=k3=0;
- printf("请输入任意字符按 F6 结束!\n");
- while ((c=getchar())!=EOF)
- {
- if (c == ' ') ++k1;
- else if (c == '\t') ++k2;
- else if (c == '\n') ++k3;
- else if (c == '0') ++a[0];
- else if (c == '1') ++a[1];
- else if (c == '2') ++a[2];
- else if (c == '3') ++a[3];
- else if (c == '4') ++a[4];
- else if (c == '5') ++a[5];
- else if (c == '6') ++a[6];
- else if (c == '7') ++a[7];
- else if (c == '8') ++a[8];
- else if (c == '9') ++a[9];
- else ++others;
- }
- printf("空格=%d个,Tab=%d个,回车=%d个,\n0=%d个,1=%d个,2=%d个,3=%d个,4=%d个,\n5=%d个,6=%d个,7=%d个,8=%d个,9=%d个\nothers%d个",k1,k2,k3,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],others);
- system("pause");
- }
复制代码
|
|