Guest User

Untitled

a guest
May 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include <iostream>
  2. int main()
  3. {
  4. int sum = 0, value = 0;
  5. //讀取數據直到遇到end-of-file,計算所有讀入的值的和
  6. while (std::cin >> value)
  7. sum += value; //等價於sum = sum + value
  8. std::cout << "Sum is: " << sum << std::endl;
  9. return 0;
  10. }
Add Comment
Please, Sign In to add comment