C++高分求助!A + B Problem II
来源:百度知道 编辑:UC知道 时间:2024/06/23 14:54:10
在杭电上做的1002,大数相加A+B问题2;提交时很多次都是提示我答案错误;高手来看看哪里错了~~指出一下,thank u!
题目:
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
题目:
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
为什么是败笔啊,其实真正用C写的基本上没有了,再说现在编译器谁还守着C一种语言啊
cout是的A
输入20次可以这样来解决:
int i=0;
while(cin>>x)
{
……
……
i++;
}
该问题没有什么很高深的算法凡是一个高精度数相加问题,对于高精度数可以通过数组来处理。至于具体的实现,我想你自己也可以写出来了。
acm int main(){return 0;}用void会错的
#include<iostream>
using namespace std;
void main()
{
char in1[1000],in2[1000];
int line;
cin >> line;
int i = 1;
while(i<=line)
{
cin>>in1;
cin.get();
cin>>in2;
cout << "Case "<<i<<":\n";
cout <<in1<<" + "<<in2<<" = ";
int len1 = strlen(in1);
int len2 = strlen(in2);
int cc = 0;
int k = 0;
char *p;
if(len1 > len2) p = new char[len1+1];
else p =
p=0.5(a +b +c)是什么意思
给定正数p,q,a,b,c
P=a/(b+c)=b/(a+c)=c/(a+b),求P的值
怎么证明:在△ABC中,P=1/2(a+b+c),r=根号[(P-a)(P-b)(P-c)/p]
三角形的面积公式S=[p(p-a)(p-b)(p-c)]^0.5 p=(a+b+c)*0.5 是怎样推出来的?
求证以下公式相等;S=/p(p-a)(p-b)(p-c)p=0.5a+b+c;S=0.5absinC;S=/0.25[c方a方-(0.5c方+a方-b方)的平
A、B、C为随机事件,P(A)=P(B)=P(C)=1/4,P(AB)=0,P(AC)=P(BC)=1/16,求A、B、C全不发生概率
c++语言中if(a<b) {*p=a;a=b;b=*p;}if(a<c) {*p=a;a=c;c=*p;} if(b<c) {*p=b;b=c;c=*p;}是什么意思?谢谢
若a>0>b>c,a+b+c=1,M=b+c\a,N=a+c\b,P=a+b\c,则M,N,P之间的大小是
已知P=a/b+c=b/a+c=c/a=b.求P的值。