# day1 hdoj 1089-1096题解

2017-11-26 19:06:38来源:cnblogs.com作者:隐秀人点击

https://space.bilibili.com/3071253#!

1089

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

`    while(scanf("%d%d",&a,&b)!=EOF)`

EOF 为 end of file

`scanf("%d%d",&a,&b);`

1090

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

`while(n>0)    {        n--;   }`

1091

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

1092

`#include<stdio.h>int main(){    int a,n;    while(scanf("%d",&n)!=EOF)    {        if （n==0）break;int sum=0;         //特别注意sum赋值0的位置        while(n>0)            {n--;            scanf("%d",&a);            sum+=a;            }        printf("%d/n",sum);    }    return 0;}`

1093

`#include<stdio.h>int main(){    int a,n,i;    scanf("%d",&i);    while(i>0)    {        i--;    scanf("%d",&n);    {        if(n==0) break;        int sum=0;        while(n>0)            {n--;            scanf("%d",&a);            sum+=a;            }        printf("%d/n",sum);    }    }    return 0;}`

1090和1092综合

1094

`#include<stdio.h>int main(){    int a,n;    while(scanf("%d",&n)!=EOF)    {        int sum=0;        while(n--){        scanf("%d",&a);        sum+=a;        }        printf("%d/n",sum);    }    return 0;}`

1095

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

1096

`#include<stdio.h>int main(){    int n,i,a;    scanf("%d",&n);    while(n--)    {        scanf("%d",&i);        int sum=0;        while(i--)        {            scanf("%d",&a);            sum+=a;        }        if(n>0)        printf("%d/n/n",sum);        else        printf("%d/n",sum);    }    return 0;}`