Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active October 30, 2016 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokomokohitsuzi/23bdf7177e1bf1e0d3b26cb953ec7708 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/23bdf7177e1bf1e0d3b26cb953ec7708 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習4-6-1
import java.util.Scanner;
public class En4_6_1 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("何個*を表示しますか:");
int n = stdIn.nextInt();
int i = 0;
while (i < n) {
System.out.print('*');
i++;
}
if (n > 0) {
System.out.println();//0より大きい場合は、改行文字を出力。
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment