Reading an unknow number of Inputs
来源:互联网 发布:奇爱博士讲电影知乎 编辑:程序博客网 时间:2024/04/30 07:03
take a look at the fllow program:
#include <iostream>
int main()
{
int sum=0,value;
while(std:cin>>value)
{
sum+=value;
}
std:cout<<"sum value is :"<<sum<<end;
reutnr 0;
}
The input operator return its left operand.The condition tests that result,meaning it tests std:cin.
When we use the iostream as a condition,the effect is to test the state of the stream. if the stream is valid,that is ,if it is still possible to read another input-then the test is successeds.
An istream becomes invalid when we hit end-of-file or encounter an invalid input,such as reading a value that is not an integer. An istream that is invalid state will cause the condition to fail.
Operating Systems uses different value for end-of-file.On Window Systems we enter a end-of-file by typing a control -z -simultaneousely type the "ctr" key and a "z".On Unix system ,includeing Mac -OS-X machines ,it is usually control-d.
- Reading an unknow number of Inputs
- read unknown number of inputs
- Reading an ID Number from a Scanned Form
- Reading the Value/Offset of an IFD Entry
- Reading given number of bytes with RSocket::Read()
- Change Number to English By Reading rule of money
- Catch the port number of an Url
- the pleasures of reading in an age of distraction 再读一遍
- #Paper Reading# X-means:Extending K-means with Efficient Estimation of the Number of Clusters
- Reducing the Number of Gray Levels in an Image
- Get nth Max number in an array of unsorted integers.
- Set the number format of cells in an Excel file
- 代码面试题:Find two smallest number of an array
- Counting-the-number-of-set-bits-in-an-integer
- rounding to an arbitrary number of significant digits
- [leetcode323]Number of Connected Components in an Undirected Graph
- LeetCode 323. Number of Connected Components in an Undirected Graph
- leetcode Number of Connected Components in an Undirected Graph
- 多线程
- QSqlRelationalTableModel的setFilter()问题
- sql2005如何還原master數據庫
- 使用cookies实现浏览历史记录功能
- java代码运行顺序-static main
- Reading an unknow number of Inputs
- 我的平行线
- 积分啊
- socket 中send 和recev函数详解
- 杀死linux的僵尸进程
- 程序员编程艺术:第十章、如何给10^7个数据量的磁盘文件排序
- 刹车防抱死系统(ABS)
- mysql查询结果导出到文件另一方法
- the Primitive Built-in Types bool