1.编写一个java应用程序,用循环结构打印如下的数值列表: N 10*N 100*N 1000*N 1 10 100 1000 2 20 200 2

2025-03-25 06:02:44
推荐回答(4个)
回答1:

public class test {
public static void main(String args[]){
System.out.println("N\t10*N\t100*N\t1000*N");
for(int i=1;i<=5;i++){
System.out.print(i+"\t");
for(int j=1;j<=3;j++){
int val = i;
for(int k=1;k<=j;k++)
val *= 10;
System.out.print(val+"\t");
}
System.out.println();
}
}
}

回答2:

public class test {
public static void main (String args[ ]) {
System.out.print("N"+"\t"+"10*N"+"\t"+"100*N"+"\t"+"1000*N");
System.out.println();
for(int i=1;i<3;i++){
int n=i;
System.out.print(n+"\t");
for(int j=1;j<4;j++){
n=n*10;
System.out.print(n+"\t");
}
System.out.println();
}

}
}

回答3:

lass A{
public static void main(String args[]){

for (int i=1; i<7;i++){
for ( int j=1; j<=4;j++){

if(i==1){
if(j==1)System.out.print("N ");
else System.out.print((int)Math.pow(10,j-1)+"*N ");

}

else System.out.print((int)((i-1)*Math.pow(10,j-1))+" ");}
System.out.println();

}

}
}

运行过了 可以的

回答4:

sda