#30142: 解答 : c++


mephistoxfaust@gmail.com (舟梅浮永不逆)


用int設整數變數a 與 b while判定若有輸入值 則輸出a+b

#include<iostream>
using namespace std;

int main()
{
    int a, b;
    while( cin >> a >> b  )
    {
        cout << a+b << endl;
    }
    return 0;
}

#30164: Re: 解答 : c++


gaspardthegenius (gaspard)


用int設整數變數a 與 b while判定若有輸入值 則輸出a+b

#include
using namespace std;

int main()
{
    int a, b;
    while( cin >> a >> b  )
    {
        cout << a+b << endl;
    }
    return 0;
}

其實你可以強制輸入