C语言或C++输入输出问题

如题所述

第1个回答  2015-03-09

输入用scanf(),输出用printf(),代码如下:

#include <stdio.h>
int main()
{
    int a, b;
    while(1) {
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0) {
            return 0;
        }
        printf("%d\n", a+b);
    }
    return 0;
}

第2个回答  2015-03-09
#include <iostream>
using namespace std;
int main(){
    int a,b,n[100],i=0;
    while(1){
        cin>>a>>b;
        if(a==0 && b==0)
            break;
        else
            n[i]=a+b;
        
        i++;
    }
    
    for(int j=0;j<i;j++)
        cout<<n[j]<<endl;
     
    return 0;
}

上面的都没有仔细看题

本回答被网友采纳
第3个回答  2015-03-09
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a==0&&b==0)
            break;
        cout<<a+b<<endl;
     }  
     return 0;
}

相似回答
大家正在搜