几行几列的图像或数字;
外层for 表示行;
内层for表示列【每一列中有多少元素】
九九乘法表:
eg:9行9列!!
代码:
for (int i =1; i
for (int j = 1; j ; j++) {
System.out.print(j +"*" + i +"="+ (i*j) +"\t");
}
System.out.println();
}
代码:
for (int i = 1; i
for (int j = 1; j j++) {
System.out.print("@");
}
System.out.println();
}
代码:
for (int i =1 ; i
for (int a = 5; a >=i; a--) {
System.out.print(" ");
}
for (int j =1 ; j ; j++) {
System.out.print("@");
}
System.out.println();
}
代码:
for (int i = 1; i
for (int j = 5; j >=i; j--) {
System.out.print("@");
}
System.out.println();
}
代码:
for (int i = 1; i
for (int j =1; j ; j++) {
System.out.print("@");
}
System.out.println();
}
代码:
for (int i =1 ; i
for (int a = 5; a >=i; a--) {
System.out.print(" ");
}
for (int j =1 ; j ; j++) {
System.out.print("@");
}
System.out.println();
}
代码:
for (int i = 1; i
for (int j =9; j >=2*i-1; j--) {
System.out.print("@");
}
System.out.println();
}
代码:
for (int i = 1; i
for (int a = 0; a ; a++) {
System.out.print(" ");//正的空格三角形把*顶过去
}
for (int j = 5; j >=i; j--) {
System.out.print("*");
}
System.out.println();
}
代码:
for (int i = 1; i
for (int j = 1; j ; j++) {
System.out.print(cc);
cc++;
if (cc == 9) { //当个数编程9的时候!
cc = 1; //给cc 重新赋值
}
}
System.out.println();
}
代码:
for (int i =1 ; i
for (int j =1 ; j ; j++) {
System.out.print(i);
}
System.out.println();
}
判断一个数字是不是存在与数组中, 存在输出存在 不存在输出不存在
代码:
System.out.println("请输入是否存在数字");
Scanner sc=new Scanner (System.in);
int [] arr1={1,23,4,2,56,18,9};
boolean boo=true;
int shu=sc.nextInt();
for (int i = 0; i < arr1.length; i++) {
if (arr1[i]==shu) {
System.out.println(arr1[i]+"存在");
boo=false;
}
}
if(boo) {
System.out.println("不存在");
}