#include<iostream>
int main()
{
int sum = 0, value = 0;
while (std::cin >> value) {
sum += value;
}
std::cout << sum << std::endl;
std::cin.get();
}
参考:C++primer 1.4.3
#include<iostream>
int main()
{
int sum = 0, value = 0;
while (std::cin >> value) {
sum += value;
}
std::cout << sum << std::endl;
std::cin.get();
}
参考:C++primer 1.4.3