好久没有写程序,习题5.2。for,getchar等的用法,
2005-04-21 22:39
393 查看
#include <stdio.h>
main()
{
char c;
int n,letter=0,space=0,num=0,other=0;
for (n=0;(c=getchar())!='/n';n++)
{ printf ("%c",c);
if (c>='a'&&c<='z'||c>='A'&&c<='Z') letter++;
if (c>='0'&&c<='9') num++;
if (c==' ') space++;
}
other=n-letter-num-space;
printf ("n=%d letter=%d num=%d space=%d other=%d",n,letter,num,space,other);
getch();
}
分别统计出,自己输入的字符,有多少个,字母,数字,其他,都是多少。
发现自己在字母上编程有很大问题。
我要努力。
main()
{
char c;
int n,letter=0,space=0,num=0,other=0;
for (n=0;(c=getchar())!='/n';n++)
{ printf ("%c",c);
if (c>='a'&&c<='z'||c>='A'&&c<='Z') letter++;
if (c>='0'&&c<='9') num++;
if (c==' ') space++;
}
other=n-letter-num-space;
printf ("n=%d letter=%d num=%d space=%d other=%d",n,letter,num,space,other);
getch();
}
分别统计出,自己输入的字符,有多少个,字母,数字,其他,都是多少。
发现自己在字母上编程有很大问题。
我要努力。
相关文章推荐
- 微信小程序wx:for和wx:for-item的正确用法
- 微信小程序wx:for和wx:for-item的用法详解
- 小程序wx:for、wx:for-items和wx:for-item的正确用法
- WaitForSingleObject的用法-(判断一个程序是否结束)
- 好久没有写DELPHI程序了
- 好久没有写程序了,准备学习学习Ajax
- 笨办法学python笔记(习题32)——range()、append()用法,以及for循环用法
- bat命令行程序:for命令的用法
- WaitForSingleObject的用法-(判断一个程序是否结束)
- 好久没有写AJAX程序了,突然傻了,缓存惹的祸
- [习题]给初学者的范例,多重字段搜寻引擎 for GridView,兼论 SqlDataSource与SelectParameter的用法
- 初学OpenCV3,运行编程入门上读取并播放视频的原版程序,编译通过但是没有任何输出,已按网上博主各种方法试,还是没有结果,大家看怎么解决?
- startActivityForResult、setResult的用法
- shell Learning [for 的用法]
- NSDate与NSDateFormatter的相关用法
- mvc3 DropDownListFor的初略用法介
- 以后就没有这么多时间天天写程序了……
- 用AVPlayer写视频播放器时,在被释放之后 ,AVPlayer一直监听的事件没有被移除,造成程序崩溃
- [导入]AjaxPanel自定义控件实现页面无刷新数据交互(做了个示例程序, 效果确实比较Cool, 用法非常简单! )(示例代码下载)
- 把.NET程序部署到没有安装.NET Framwork的机器上