我写了一个好蠢的程序
26 November 2020 -
less than 1 min read time
Tags:
Java
一个很蠢的程序
package com.cg.helloworld;
import java.util.Scanner;
public class Exercise1 {
public static void main(String[] args){
Scanner a=new Scanner(System.in);
int b=a.nextInt();
if(b<=0){
System.out.println("-1");
}
else{
int[] array1=new int[3];
array1[2]=(b-b%100)/100;
array1[1]=(b%100-b%10)/10;
array1[0]=b%10;
if(array1[0]==0 && array1[1]==0 )
System.out.print(array1[2]);
else if(array1[0]==0 && array1[1]!=0){
System.out.print(array1[1]);
System.out.print(array1[2]);
}
else {for (int k:array1
) {
System.out.print(k);
}
}
};
}
}