0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

解いてみた。「Dランク:N倍の文字列」

Posted at

問題

「Dランク:N倍の文字列」

コード

Javaで解いてみました。

import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int nN = sc.nextInt();

        for (int i = 0; i < nN; i++) {
            System.out.print("*");
        }

        System.out.println("");
    }
}

解説

標準入力からの数値の読み取り

Scanner インスタンスを作り、nextInt()メソッドで数値を取得しています。

文字('*')の表示

ループを nN 回まわして、print() メソッドで '*' を表示しています。
(※ println() メソッドを使うと、改行が入るので不適。)

最後に改行するため、println() メソッドを呼んでいます。

0
0
0

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
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?