编写程序从cin读取一组数,输出其和

#include <iostream>
using namespace std;
int main()
{
    int num, sum = 0;
    while (cin >> num)
    {
        sum += num;
    }
    cout << sum << endl;
    return 0;
}

 

posted @ 2018-10-08 22:32  ppwq  阅读(338)  评论(0编辑  收藏  举报