import javax.swing.JOptionPane;
public class lab {
public static void main(String[] args) { //don't comment this out
// TODO Auto-generated method stub
String output = "";
for (int x = 1; x <= 4; x++)
{
for (int y = 0; y <= 9; y++)
{
output = output + x*y + " ";
}
output = output + "\n";
}
JOptionPane.showMessageDialog(null,output);
}
}//我需要创建一个程序来显示一个表格
1 0 1 2 3 4 5 6 7 8 9
2 0 2 4 6 8 10 12 14 16 18
3 0......................
4 0....................... 到目前为止,我的程序从0开始。我想知道如何从1,2,3,4的第一列开始,然后从0,0,0,0的第二列开始编码
发布于 2016-02-06 13:12:09
试着这样做:
public class test {
public static void main(String args[]) {
String output = "";
for (int x =1; x <= 4; x++) {
output += x + " ";
for (int y = 0; y <= 9; y++) {
output = output + x*y + " ";
}
output = output + "\n";
}
JOptionPane.showMessageDialog(null,output);
}
}https://stackoverflow.com/questions/35237507
复制相似问题