the c program1.8
来源:互联网 发布:农村淘宝服务站怎么赚钱 编辑:程序博客网 时间:2024/05/22 04:50
编写一个用于统计空格、制表符与换行符个数的程序
#include <iostream>using namespace std;int main(){int c;int blanks;int tabs;int newlines;blanks=0;tabs=0;newlines=0;while ((c=getchar()) != EOF){if (c == ' ') blanks++;if (c == '\t')tabs++;if (c == '\n')newlines++;}cout<<blanks<<endl;cout<<tabs<<endl;cout<<newlines<<endl;return 0;}//int main()//{// int blanks, tabs, newlines;// int c;// int done = 0;// int lastchar = 0;// // blanks = 0;// tabs = 0;// newlines = 0;// // while(done == 0)// {// c = getchar();// // if(c == ' ')// ++blanks;// // if(c == '\t')// ++tabs;// // if(c == '\n')// ++newlines;// // if(c == EOF)// {// if(lastchar != '\n')// {// ++newlines; /* this is a bit of a semantic stretch, but it copes// * with implementations where a text file might not// * end with a newline. Thanks to Jim Stad for pointing// * this out.// */// }// done = 1;// }// lastchar = c;// }// // printf("Blanks: %d\nTabs: %d\nLines: %d\n", blanks, tabs, newlines);// return 0;//}
0 0
- the c program1.8
- Program1
- Program1-1
- win7开机后出现将其更名为“将其更名为'c:\program1‘”的文件名警告
- 剑指offer编程练习(Program1)
- 读《The C Programming Language》(8)
- The C Programming Language 练习题2-8
- C - The C Answer (2nd Edition) - Exercise 1-8
- The MD4 Class.(C#)
- C++: Under the Hood
- The C programming language___1d
- The C programming language___2d
- C++: The Complete Reference
- C++: Under the Hood
- C++: Under the Hood
- The GNU C Library
- The MD4 Class.(C#)
- The MD4 Class.(C#)
- 求一元二次方程的根:浮点数中的“0”
- eclipse中的R出现的问题
- 一维数组的初始化问题
- 装饰者模式&代理模式
- 贪心算法精讲
- the c program1.8
- 【计算机网络常见面试题】ip地址同一网段计算问题
- 的合法几点回家
- prevision-recall 曲线
- Java IO流和文件
- C# yield
- 十一
- $GLOBALS["HTTP_RAW_POST_DATA"]
- 保护措施