Skip to content

Instantly share code, notes, and snippets.

View wdfx100's full-sized avatar

wangxu wdfx100

View GitHub Profile
@wdfx100
wdfx100 / java
Created December 6, 2012 12:44
冒泡排序
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;//大的往后移
}
}
}
@wdfx100
wdfx100 / code
Created December 6, 2012 03:56
猜数字
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();
@wdfx100
wdfx100 / 第一个code
Created December 6, 2012 03:55
数字取反
//数字取反
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);