【新手】为什么小弟我用long long老是出错
【新手求助】为什么我用long long老是出错
题目是一道杭电OJ上的题(1002)
**********************************************************************************************
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Case 1:
1 + 2 = 3
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110
************************************************************************************************
然后我写的程序是这样的
#include<stdio.h>
int main()
{
int t,i;
long long a,b;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%I64d %I64d",&a,&b);
printf("case %d:\n",i);
printf("%I64d+%I64d=%I64d\n",a,b,a+b);
}
return 0;
}
我的是32位系统的电脑,是在codeblocks上运行的,是可以通过的,而且感觉运行结果是对的,可是提交的时候总是WA,我看了下别人AC的答案,看他们都是用数组做的
其实我就是想知道我这样的解法是不是正确的
还有求教下大神long long数据类型的用法
求大神指点迷津啊!!!感激不尽
------解决方案--------------------
You may assume the length of each integer will not exceed 1000.
long long够用?
------解决方案--------------------
接4L,所以说long long根本放不下题目中最大的数。
这是典型的大数计算。
char a[999], b[999], result[1000];
a + b,结果放入result中
------解决方案--------------------
模拟小学加法
------解决方案--------------------
随便写的。
题目是一道杭电OJ上的题(1002)
**********************************************************************************************
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Case 1:
1 + 2 = 3
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110
************************************************************************************************
然后我写的程序是这样的
#include<stdio.h>
int main()
{
int t,i;
long long a,b;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%I64d %I64d",&a,&b);
printf("case %d:\n",i);
printf("%I64d+%I64d=%I64d\n",a,b,a+b);
}
return 0;
}
我的是32位系统的电脑,是在codeblocks上运行的,是可以通过的,而且感觉运行结果是对的,可是提交的时候总是WA,我看了下别人AC的答案,看他们都是用数组做的
其实我就是想知道我这样的解法是不是正确的
还有求教下大神long long数据类型的用法
求大神指点迷津啊!!!感激不尽
杭电OJ
数据类型
long long
------解决方案--------------------
You may assume the length of each integer will not exceed 1000.
long long够用?
------解决方案--------------------
接4L,所以说long long根本放不下题目中最大的数。
这是典型的大数计算。
char a[999], b[999], result[1000];
a + b,结果放入result中
------解决方案--------------------
模拟小学加法
------解决方案--------------------
随便写的。
$ cat x.c
# include <stdio.h>
# include <string.h>
void reverse(char * s)