acm 1002 老是Presentation Error package one;import java.util.Scanner;public class Main {public static void main(String[] args) {int n,j=1;String a,b;char[] a1,b1;int[] sum1,a2,b2;Scanner in = new Scanner(System.in);n = in.nextInt();while ((n--) > 0

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 13:47:40
acm1002老是PresentationErrorpackageone;importjava.util.Scanner;publicclassMain{publicstaticvoidmain(St

acm 1002 老是Presentation Error package one;import java.util.Scanner;public class Main {public static void main(String[] args) {int n,j=1;String a,b;char[] a1,b1;int[] sum1,a2,b2;Scanner in = new Scanner(System.in);n = in.nextInt();while ((n--) > 0
acm 1002 老是Presentation Error
package one;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n,j=1;
String a,b;
char[] a1,b1;
int[] sum1,a2,b2;
Scanner in = new Scanner(System.in);
n = in.nextInt();
while ((n--) > 0) {
a = in.next();
b = in.next();
int maxlen = a.length() > b.length() a.length() :b.length();
a1 = new char[a.length()];
b1 = new char[b.length()];
a2 = new int[maxlen];
b2 = new int[maxlen];
a.getChars(0,a.length(),a1,0);
b.getChars(0,b.length(),b1,0);
sum1 = new int[maxlen + 1];
System.out.println("Case "+(j++)+":");
System.out.print(new String(a1)+" + "+new String(b1)+" = ");
a1 = renew(a1);
b1 = renew(b1);
for (int i = 0; i < maxlen; i++) {
if (i < a1.length) {
a2[i] = a1[i] - '0';
}else {
a2[i]=0;
}
}
for (int i = 0; i < maxlen; i++) {
if (i < b1.length) {
b2[i] = b1[i] - '0';
}else {
b2[i]=0;
}
}
sum1 = new int[maxlen + 1];
for (int i = 0; i < maxlen; i++) {
sum1[i] = 0;
}
for (int i = 0; i < maxlen; i++) {
sum1[i] = sum1[i] + a2[i] + b2[i];
if (sum1[i] >= 10) {
sum1[i] = sum1[i] % 10;
sum1[i + 1] = 1;
}
}
if(sum1[maxlen]==0)
{
maxlen=maxlen-1;
}
for (int i = 0; i < maxlen + 1; i++) {
System.out.print(sum1[maxlen-i]);
}
System.out.print("\n"+"\n");
}
}
public static char[] renew(char[] old) {
char[] newly = new char[old.length];
for (int i = 0; i < old.length; i++) {
newly[i] = old[old.length - i - 1];
}
return newly;
}
}

acm 1002 老是Presentation Error package one;import java.util.Scanner;public class Main {public static void main(String[] args) {int n,j=1;String a,b;char[] a1,b1;int[] sum1,a2,b2;Scanner in = new Scanner(System.in);n = in.nextInt();while ((n--) > 0
Presentation Error 是格式错误,你确定没有多的空行空格出现?
由于没有题目信息,所以不清楚输出格式的具体要求.你可以看下输出结果和标准输出是否有出入.
还有就是所有输出的最后是否多了一行空行,这是常出的PE的一种.