Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.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打印数学时间表(特定数字的整个时间表)_Java_Python_Php - Fatal编程技术网

如何用java打印数学时间表(特定数字的整个时间表)

如何用java打印数学时间表(特定数字的整个时间表),java,python,php,Java,Python,Php,我正在学习编程,最近遇到了一个挑战,就是打印一个用户输入的特定数字的数学时间表。假设输入的数字是10,那么表格应按如下方式打印 我用下面的代码打印了输入号码的时间表。但不是整张桌子上的数字 Scanner scan= new Scanner(System.in); int input= scan.nextInt(); int value=1; for(int i=1; i<=input; i++){ value= i*input;

我正在学习编程,最近遇到了一个挑战,就是打印一个用户输入的特定数字的数学时间表。假设输入的数字是10,那么表格应按如下方式打印

我用下面的代码打印了输入号码的时间表。但不是整张桌子上的数字

    Scanner scan= new Scanner(System.in);
    int input= scan.nextInt();
    
    int value=1;
    for(int i=1; i<=input; i++){
     value= i*input;
     System.out.println(value);
    }
    
       Output: 
       10
       20
       30
       40
       50
       60
       70
       80
       90
       100
       ------------------------------------------------------------------------
       BUILD SUCCESS
       ------------------------------------------------------------------------
Scanner scan=新的扫描仪(System.in);
int input=scan.nextInt();
int值=1;

对于(int i=1;i来说,输出的想法是打印矩阵形式的解决方案,因此更好的选择是对嵌套循环使用两个,您将打印的矩阵是(input x input)大小


这是否回答了您的问题?请不要滥用不同编程语言/技术的多个标记,让您的问题更加集中。因为您需要10行,每行10列,所以需要一个嵌套循环。我看不到有人试图这样做。对于Python,我将检查我是否也可以将答案应用于Python和PHP
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();

for(int i=1; i<=input; i++){
    for(int j=1; j<=input; j++){
        System.out.print(i*j + " ");
    }
    System.out.print("\n");
}
1 2 3 4 5 6 7 8 9 10 
2 4 6 8 10 12 14 16 18 20 
3 6 9 12 15 18 21 24 27 30 
4 8 12 16 20 24 28 32 36 40 
5 10 15 20 25 30 35 40 45 50 
6 12 18 24 30 36 42 48 54 60 
7 14 21 28 35 42 49 56 63 70 
8 16 24 32 40 48 56 64 72 80 
9 18 27 36 45 54 63 72 81 90 
10 20 30 40 50 60 70 80 90 100