Problem 1000:A + B Problem
Problem Description
Calculate A + B.

Input
Each line will contain two integers A and B. Process to end of file.

Output
For each case, output A + B in one line.

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

第一题其实我submit就是wrong answer,主要注意格式,输出要加上换行符;


Problem 1001:Sum Problem
Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.

Input
The input will consist of a series of integers n, one integer per line.

Output
For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.

#include<stdio.h>
int main()
{
    int m;
    while(scanf("%d",&m)!=EOF)
    {
        int sum=0;
        for(int k=0;k<=m;k++)    sum+=k;
        printf("%d\n\n",sum);
    }
    return 0;
}

要是数字大点的话用递归做大概是会超出深度吧


1122334455+9988776655
66778899+44332211

111111110
11111111110

include <stdio.h>

include <string.h>

int main()
{

int n;
scanf("%d%",&n);
while(n--)
{
    char str1[]={0};
    char str2[]={0};
    char str3[]={0};
    puts(str1);
    puts(str2);
    if(strlen(str1)>=strlen(str2))
    {
        int m=strlen(str2)-1;
        int flag=0;
        for(int a=m;a>0;a--)
        {
            int num=int(str1[m])+int(str2[m])+flag;
            if(num>=10)
                {
                    add=num%10;
                    flag=1;
                }
            else
                {
                    add=num;
                    flag=0;
                }
            strcat(char(add),str3);
    }
}
}
return 0;

}