笔记:
1.流->从IO设备上读入或写出的字符序列,用来说明字符随时间顺序生成或消耗。
2.输入输出符可连用原因:operator<<或operator>>返回stream对象。
3.要测试程序那个语句出错,使用cout<<......<<endl;不用endl刷新用可能让...中的字符保留在缓冲区使错误语句位置判断错误。
4.新建一个内置类型,如int i=0;最好先初始化,不然用到的时候没初始化会产生奇怪的错误。
#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){int x,y,lower,uper;cout<<"Input two number of the range that you want to show:"; cin>>x>>y; if (x>=y) {lower=y;uper=x; } else {lower=x;uper=y; }cout<<"\nThe range number show:"<<endl;//for
(;lower<=uper;lower++) // cout<<lower<<"\t";for (int i=0;lower<=uper;lower++){if (i==10){cout<<endl;//i=10的时候已经是第11个数了,故i重新设置为1;i=1;}elsei++;cout<<lower<<"\t";}return 0;}

本文介绍了C++中流的概念及如何使用输入输出操作符,并通过一个示例程序展示了如何利用循环来显示指定范围内的整数。同时强调了程序调试技巧和变量初始化的重要性。
671

被折叠的 条评论
为什么被折叠?



