C++输入不确定数量的数字

#include<iostream> 
using namespace std;
int main(){
	int value,sum=0;
	while(cin>>value){
		sum+=value;
	}
	cout<<"The sum of the values is "<<sum;
	return 0;
}

按非法字符或CTRL+Z+enter中止

猜你喜欢

转载自blog.csdn.net/zhao2chen3/article/details/87888275