Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/376.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/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/1/vb.net/17.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 带for循环的乘法表_Java_Loops_For Loop - Fatal编程技术网

Java 带for循环的乘法表

Java 带for循环的乘法表,java,loops,for-loop,Java,Loops,For Loop,我需要为做一个循环,这个循环将显示数字为1到10的1,2,3的乘法表 应该是这样的。提前谢谢你 您可以创建从1到10的循环,然后将它们乘以1,2,3,然后显示它们 您可以创建3个最终变量来存储1,2,3 可能性真的很大;) for(int i=0;i 无标题 $(函数(){ $(“.button”)。单击(函数(){ var n=document.getElementById(“num”).value; var-arr=[]; 对于(i=0;i您可以尝试以下代码。它将以您想要的方式显示表格:

我需要为做一个循环,这个循环将显示数字为1到10的1,2,3的乘法表


应该是这样的。提前谢谢你

您可以创建从1到10的循环,然后将它们乘以1,2,3,然后显示它们 您可以创建3个最终变量来存储1,2,3 可能性真的很大;)

for(int i=0;i

无标题
$(函数(){
$(“.button”)。单击(函数(){
var n=document.getElementById(“num”).value;
var-arr=[];

对于(i=0;i您可以尝试以下代码。它将以您想要的方式显示表格:

public class MyClass {
    public static void main(String args[]) {
        int x= 1;
        int y= 2;
        int z= 3;
        int temp;
        for(temp=1;temp<=10;temp++)
            System.out.println(temp + "\t" + x*temp + "\t" + y*temp +"\t" + z*temp);
    }
}

请发布您的代码或代码尝试,以及您的测试、输入和输出
<!DOCTYPE HTML>

<html>
<head>
<title>Untitled</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
     $(function(){
        $( ".button" ).click(function() {
            var n = document.getElementById( "num" ).value;
                var arr = [];
                for (i=0; i<n; i++)
                arr[i] = [];
                var sub = 1;
                var count = 1;
                i = 0;
                while (count <= n){
                var loopcount = 1;
                while (loopcount <= n){
                    arr[i].push(sub);
                    sub += count;
                    loopcount++;
                }
                count++;
                sub = count;
                i++;
                }

             var $table = $("<table></table>");
              var $row;
              arr.forEach(function(subArr){ // using forEach will execute the parameter function for every element (subarray)
                $row = $("<tr></tr>"); // create a new row
                subArr.forEach(function(el){ // now another forEach function, this time adding cells to the row
                  $row.append('<td>' + el + '</td>');
                });
                $table.append($row);
              });
              $table.appendTo(document.body);

            });
     });
</script>
</head>
<body>
<div class="wrapper">
    <h1>Generate multiplication tables</h1>
    <form>
        <label for="num">Choose number of rows</label>
        <input type="text" value="" id="num"/>
        <input type="button" value="Submit" class="button"/>
        <p id="answer"></p>
        <div id="myDiv"></div>
    </form>

</div>
</body>
</html>
public class MyClass {
    public static void main(String args[]) {
        int x= 1;
        int y= 2;
        int z= 3;
        int temp;
        for(temp=1;temp<=10;temp++)
            System.out.println(temp + "\t" + x*temp + "\t" + y*temp +"\t" + z*temp);
    }
}
1   1   2   3
2   2   4   6 
3   3   6   9
4   4   8   12 
5   5   10  15
6   6   12  18
7   7   14  21
8   8   16  24
9   9   18  27
10  10  20  30