package TestCode;
/*打印结果
1 ** * * ******
1234567890abcd5fghi0klmn5pqrs0uvwx5z
1 11 12 19 25 29 30 31 32 33 34
* * * * * *
1234567890abcdefghi0klmn5pqrs0uvwxyz
1 10 13 19 25 29
* * * * * ******
1234567890abcdefghijklmnopqrstuvwxyz
1 9 14 19 25 29 30 31 32 33 34
* * * * * *
1234567890abcdefghijklmnopqrstuvwxyz
1 10 13 20 24 29
****** ** *** ******
123456 11 12 21 22 23 29 30 31 32 33 34*/
public class LOVE {
public static void main(String[] args) {
int [] arr1 = {1,11,12,19,25,29,30,31,32,33,34};
int [] arr2 = {1,10,13,19,25,29};
int [] arr3 = {1,9,14,19,25,29,30,31,32,33,34};
int [] arr4 = {1,10,13,20,24,29};
int [] arr5 = {1,2,3,4,5,6,11,12,21,22,23,29,30,31,32,33,34};
print(arr1);
print(arr2);
print(arr3);
print(arr4);
print(arr5);
}
public static boolean isIn(int [] arr, int a){
boolean b = false;
for (int i = 0;i<arr.length ;i++ ) {
if (a == arr[i]) {
b = true;
}
}
return b;
}
public static void print(int [] arr){
for (int i = 1; i <= arr[arr.length-1] ; i++) {
boolean b = isIn(arr,i);
if (b) {
System.out.print("*");
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
打印试试看 |