我正在研究 Reges、Stuart 和 Martin Stepp 的第 2 章自检问题。构建 Java 程序:回归基础的方法。我试图得到下面的输出与我的代码。我正在尝试确定to toline
关系!
以及计算. 这不是家庭作业,我也不需要答案,方向或指导是我所寻求的。\
/
for loops
!!!!!!!!!!!!!!!!!!!!!!
\\!!!!!!!!!!!!!!!!!!//
\\\\!!!!!!!!!!!!!!////
\\\\\\!!!!!!!!!!//////
\\\\\\\\!!!!!!////////
\\\\\\\\\\!!//////////
我现在的代码是:
/**
* Created on 8/28/15.
* Following Reges, Stuart, and Martin Stepp. Building Java Programs: A Back to Basics Approach.
* Chapter 2 Self-Check Problems
*/
public class Ch2_SelfCheckProblems {
public static void main(String[] args) {
question34();
}
public static void question34(){
/**
* Table
* Line 1 ! = 22 \ = 0 / = 0
* Line 2 ! = 18 \ = 2 / = 2
* Line 3 ! = 14 \ = 4 / = 4
* Line 4 ! = 10 \ = 6 / = 6
* Line 5 ! = 6 \ = 8 / = 8
* Line 6 ! = 2 \ = 10 / = 10
*/
for (int line = 1; line <= 6; line++){
for (int i = 1; i <= 22; i++){
// for (int j = 1; j <= (line - 1); j++){
// System.out.print("\");
// }
System.out.print("!");
}
System.out.println();
}
}
}