search
LoginSignup
0

posted at

updated at

for文の応用 谷型グラフ(累乗)

実行結果

スクリーンショット 2022-06-16 18.40.33.png

コード

メソッドの呼び出し元

public class Graph2 {
	public static void main(String[] args) {
		for(int i = -8;i <= 8;i++) {
			Graph1.printGraph(i*i);
		}
	}
}

メソッドの呼び出し先

public class Graph1 {
	public static void main(String[] args) {
		printGraph(10);
	}
	public static void printGraph(int x) {
		for (int i = 0;i < x;i++) {
			System.out.print("◯");
		}
		System.out.println();
	}
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0