#include <iostream> int main() { std::cout<<"请输入N个整数,按Ctrl+Z,然后按Enter结束"<<std::endl; int val = 0 , sum = 0 ; while(std::cin>>val) sum += val ; std::cout<<"你输入的数之和是:"<<sum<<std::endl; return 0; }
输入结束符(Ctrl+Z),或者输入错误(输入小数)结束
#include <iostream> int main() { std::cout<<"请输入N个整数,按Ctrl+Z,然后按Enter结束"<<std::endl; int val = 0 , sum = 0 ; while(std::cin>>val) sum += val ; std::cout<<"你输入的数之和是:"<<sum<<std::endl; return 0; }
输入结束符(Ctrl+Z),或者输入错误(输入小数)结束
转载于:https://www.cnblogs.com/guozhikai/p/6100242.html