Home > Net >  HDOJ 1002 additive c # programming of large number for help
HDOJ 1002 additive c # programming of large number for help

Time:09-15

Beginners c #, in line with the eyes and the familiar with the idea of code to brush the topic, the results have been WA thought very simple question, for students after know 2450584, 257, this group of data is stuck, but I don't know how to solve, therefore the code from the enclosed
Using System;
using System.Collections;
Using System. Collections. Generic;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
The namespace HDOJ_A_Plus_B_CSharp2
{
The class HDOJ1002
{
Public static void Main (string [] args)
{
int n;
The string line;
While ((line=Console. ReadLine ())!=null)
{
N=int. Parse (line);
For (int t=0; T & lt; n; T + +)
{
Int [] sum=new int [100000].

For (int i1=0; I1 & lt; 100000; I1 + +)
{
Sum (i1)=0;
}
String, line1;
String [] STR;
String a=null, b=null;
Int Lena, lenb;
Int CNT, k, k1;
, line1=Console. ReadLine ();
STR=, line1. Split (' ');
A=STR [0].
B=STR [1].
Lena=a. ength;
Lenb=b.L ength;
CNT=0;
K=Lena & gt;=lenb? Lena: lenb;
K1=k;
Int I, j;
//sum [k + 1)=0.
For (I=Lena - 1, j=lenb - 1; I & gt;=0 & amp; & J & gt;=0; I -, j -)
{
The sum [k]=(CNT + a + b [I] - [I] '0' - '0') % 10;
CNT=(a + b [j] - [I] '0' - '0' + CNT)/10;
K -;
}
If (Lena & gt; Lenb)
{
For (; I & gt;=0; I -)
{
Sum [k]=(a [I] - '0' + CNT) % 10;
CNT=(a [I] - '0' + CNT)/10;
K -;
}
}
The else
{
For (; J & gt;=0; J -)
{
Sum [k]=[j] - '0' (b + CNT) % 10;
CNT=(b [j] - '0' + CNT)/10;
K -;
}
}
Console. WriteLine (" Case {0} ", t + 1);
If (CNT==0)
{
The Console. Write (" {0} {1} +=", a, b);
For (int i1=1; I1 & lt;=k1; I1 + +)
The Console. Write (sum (i1));
Console. WriteLine (" ");
Console. WriteLine (" ");
}
The else
{
The sum [0]=CNT;
The Console. Write (" {0} {1} +=", a, b);
For (int i1=0; I1 & lt;=k1; I1 + +)
The Console. Write (sum (i1));
Console. WriteLine (" ");
Console. WriteLine (" ");
}
}
//the Console. ReadKey ();
}
}
}
}

CodePudding user response:

Since the beginning, then hurriedly in language to learn Java, Python, Go, and so on, we Go into nations, 49 years you don't to muddy water

CodePudding user response:

reference 1st floor ziqi0716 response:
since the beginning, then hurriedly in language to learn Java, Python, Go, and so on, we are in 49 in the nations, you don't to muddy water

Is a beginner, because of the work to use, I also want to use c + +
  •  Tags:  
  • C#
  • Related