Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int sum = 0, value = 0;
- //讀取數據直到遇到end-of-file,計算所有讀入的值的和
- while (std::cin >> value)
- sum += value; //等價於sum = sum + value
- std::cout << "Sum is: " << sum << std::endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment