Home > Back-end >  Addition of large Numbers of topic, I don't know where is wrong
Addition of large Numbers of topic, I don't know where is wrong

Time:05-25

Addition of large number of questions, don't know where is wrong, and measure the multiple sets of data are true, I hope the great god can help you see
Below is the code:

# include & lt; iostream>
# include & lt; Cstring>
using namespace std;



Int main () {
Int t, num=1, temp=0, u=0;
Cin & gt;> t;
While (t -) {
U++;
Char a [1005]={0}, [1005] b={0};
Int [1005] c={0}, [1005] d={0}, sum [1005]={0};
Cin & gt;> A. & gt;> b;
Int Asize=strlen (a);
Int Bsize=strlen (b);
For (int I=Asize - 1, j=0; I & gt;=0; I -) {
C=a [j++] - [I] '0'.
}

For (int I=Bsize - 1, j=0; I & gt;=0; I -) {
D=b [j++] - [I] '0'.
}


Int q=0, w=0, I=0;

For (I; I & lt; (Asize & lt;=Bsize? Asize: Bsize); I++) {
W++;
Temp=c + d [I] [I];

If (temp & gt; 9) {
Temp %=10;
The sum [I]=temp + q;
Q=1;
} else {
If (temp + q & gt; 9) {
Sum [I]=(temp) + q % 10;
Q=1;
} else {
The sum [I]=temp + q;
Q=0;
}
}
}

While (I & lt;=(Asize & gt; Bsize? Asize: Bsize)) {
If (Asize & gt; Bsize) {
Temp=c [I] + q;
} else {
Temp=d [I] + q;
}
If (temp & gt; 9) {
Temp %=10;
Q=1;
} else {
Q=0;
}
The sum [i++]=temp;
}

Cout & lt; <"Case" & lt;
For (int j=I - 1; J & gt;=0; J -) {
If (j==I - 1 & amp; & The sum [j]==0) continue;
Cout & lt; }
Cout & lt;
//for (int j=0; J & lt; i; J++) {
//cout & lt; <"The sum [" & lt; & lt; j & lt; & lt;"] : "& lt; //}

}
return 0;
}

CodePudding user response:

http://acm.hdu.edu.cn/game/entry/problem/show.php? Chapterid=2 & amp; Sectionid=3 & amp; Problemid=1 is this topic

CodePudding user response:

Verify 0 + 0
  • Related