冒泡、九九

//1、冒泡排序
public static void maoPao(){
int[] x={1,24,45,56,6,98,90,3,2,65,3};
for (int i = 0; i < x.length-1; i++) {
//外循环是轮数
for (int j = 0; j < x.length-i-1; j++) {
//内循环是次数
if(x[j+1]<x[j]){
int tem=x[j+1];
x[j+1]=x[j];
x[j]=tem;
}
}
}
for (int i = 0; i < x.length; i++) {
System.out.print(x[i]+" ");
}
}

//2.九九乘法表

public static void jiujiu(){
for(int i=1;i<10;i++){
for(int j=1; j<=i;j++){
System.out.print(j+"*"+i+"="+j*i+"\t");
}
System.out.println();
}
}

posted @ 2018-06-24 17:36  等你在这里  阅读(115)  评论(0编辑  收藏  举报