私たちの教授は問題について修正を加えました:
長方形を描いてください!
ファイル名: ActivityThree.java
入力ファイル: activitythree.in
Maritess は ASCII アートを高く評価し始めています。彼女は思い切って長方形の長さと幅を読み取るプログラムを書き始めました。指定された寸法の長方形の ASCII 描画は、ASCII 文字 '#' を使用して「描画」されます。プログラムは数値のペアを継続的に読み取る必要があります
(最初に長さ、次に幅) を入力し、入力の終わりに達した後に計算された QPI を出力します。
入力:
入力ファイルは、スペースで区切られた一連の整数のペアで構成されます。1 行に 1 組の整数。各ペアの最初の数値は長方形の長さで、もう一方の数値は幅です。
出力:
各長方形 (入力された寸法) は、文字「#」を使用して出力されます。
各描画の後に空白が必要です。
サンプル入力:
1 1
2 2
3 3
5 6
9 10
サンプル出力:
#
--------
##
##
--------------
###
###
###
-------------
#####
#####
#####
#####
#####
#####
----------------------
#########
#########
#########
#########
#########
#########
#########
#########
#########
#########
これはまだコードの可能性があります:
import java.io.*;
public class ActivityThree {
public static void main (String[] args) {
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
String input = "";
String output = "";
int a = 0;
int b = 0;
int inputParse = 0;
int outputParse = 0;
try{
System.out.print("Enter Length: ");
input = dataIn.readLine();
System.out.print("Enter Width: ");
output = dataIn.readLine();
}catch( IOException e ){
System.out.println("Error!");
}
inputParse = Integer.parseInt(input);
outputParse = Integer.parseInt(output);
for(a = inputParse; a > 0; a--){
for(b=0; b < outputParse; b++){
if(a >= inputParse)
System.out.print("#");
else
System.out.print("#");
}
System.out.print("\n");
}
}
}
どうもありがとうございます、。