Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Java每行/每行打印10位数字_Java_Loops_For Loop_Printing - Fatal编程技术网

使用Java每行/每行打印10位数字

使用Java每行/每行打印10位数字,java,loops,for-loop,printing,Java,Loops,For Loop,Printing,如何每行打印10个数字?我想要这样的输出: 1 2 3 3 4 5 6 7 8 9 10 1 4 9 16 25 36 49 64 81 100 1 8 27 64 125 216 343 512 729 1000 ................ ................... 但我现在得到的是混乱 1 1 1 1 1 2 4 8 16 32 3 9 27 81 243 4 16 64 256 1024 5 25 125 625 3125 6 36 216 1296 7776 7 4

如何每行打印10个数字?我想要这样的输出:

1 2 3 3 4 5 6 7 8 9 10
1 4 9 16 25 36 49 64 81 100
1 8 27 64 125 216 343 512 729 1000
................
...................
但我现在得到的是混乱

1 1 1 1 1 2 4 8 16 32 3 9 27 81 243 4 16 64 256 1024 5 25 125 625 3125 6 36 216 1296 7776 7 49 343 2401 16807 8 64 512 4096 32768 9 81 729 6561 59049 10 100 1000 10000 100000
这是片段

public class NumberOnly
{
    public static void main (String [] args)
    {
        for(int count = 1; count <= 10; count++) {

                 System.out.print(count + " ");
                 System.out.print((int) Math.round(Math.pow(count, 2))  + " ");
                 System.out.print((int) Math.round(Math.pow(count, 3))  + " ");
                 System.out.print((int) Math.round(Math.pow(count, 4))  + " ");
                 System.out.print((int) Math.round(Math.pow(count, 5))  + " ");
        }
    }
}
公共类编号
{
公共静态void main(字符串[]args)
{

对于(int count=1;count,请尝试以下代码。这是您想要的方式

public class NumberOnly
{
    public static void main (String [] args)
    {

        for(int i=1; i<=5; i++)
        {
            for(int j=1; j<=10; j++)
            {
                System.out.print((int)Math.round(Math.pow(j, i)) + " ");
            }
            System.out.println();
        }
    }
}
公共类编号
{
公共静态void main(字符串[]args)
{

对于(int i=1;我试过什么了吗?如果是,你能发布吗?注意,我们更喜欢技术性的写作风格。我们不鼓励问候,希望你能帮助,谢谢,提前感谢,感谢,感谢,问候,亲切的问候,签名,请你能帮我,聊天材料和缩写txtspk,恳求,你被困多久,投票建议、元评论、宗教或精神祈祷等等。只需解释你的问题,展示你的尝试、你的期望和实际发生的事情。