用for()(括号中有两个变量i,j)写出加法公式:
1 package Cforth;
2 import java .util.*
;
3 public class C4_16 {
4 public static void main(String[] args) {
5 Scanner in =
new Scanner(System.in);
6 System.out.println("请输入你想求的整数 的加法公式:"
);
7 int number=
in.nextInt();
8 for(
int i=0,j=number;i<=j;i++,j--
) {
9 System.out.println(i+"+"+j+"="+(i+
j));
10 }
11 }
12 }
測試結果:
測試成功!
转载于:https://www.cnblogs.com/Catherinezhilin/p/8398284.html