用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 }

測試結果:
java基础--for循环-写出加法公式

測試成功!

相关文章:

  • 2021-04-12
  • 2022-01-15
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2021-12-02
  • 2021-12-15
猜你喜欢
  • 2022-02-02
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2021-04-17
相关资源
相似解决方案