This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int temp; | |
for(int i=0;i<num.length-1;i++){ | |
for(int j=0;j<num.length-i-1;j++){ | |
if(num[j]>num[j+1]){ | |
temp=num[j];//大的先拿出来 | |
num[j]=num[j+1];//小的往前移 | |
num[j+1]=temp;//大的往后移 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input=new java.util.Scanner(System.in); | |
random=new java.util.Random(); | |
//取随机数 | |
int num=random.nextInt(100); | |
System.out.println(num); | |
boolean flag=true; | |
int count=0; | |
while(flag){ | |
System.out.println("请输入你的数字:"); | |
int i=input.nextInt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//数字取反 | |
java.util.Scanner input=new java.util.Scanner(System.in); | |
System.out.println("请输入要取反的数字:"); | |
int i=input.nextInt(); | |
do{ | |
int j=i%10; | |
System.out.print(j); | |
i=i/10; | |
if(i<10){ | |
System.out.print(i); |