0
0

More than 1 year has passed since last update.

paizaラーニング データセット選択メニュー 文字列の配列 Java 解答

Posted at

STEP: 5 とても大きな数値の入力

問題

解答

step5.java
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        System.out.println(line);
    }
}

結果

image.png

STEP: 6 とても小さな数値の入力

問題

解答

step6.java
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        System.out.println(line);
    }
}

結果

image.png

FINAL問題 文字列の配列

問題

解答

final.java
import java.util.*;


public class Main {
    
    private static final String YES = "Yes";
    private static final String NO = "No";
    private static final String WALL = "#";
    private static final String ROAD = ".";
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int r = sc.nextInt() -1;
        int c = sc.nextInt() -1;
        
        // 改行
        sc.nextLine();
        
        String[][] map = new String[h][w];
        for(int i = 0; i < h; i++){
            String line = sc.nextLine();
            String[] array = line.split("");
            map[i] = array;
        }
        
        if(Objects.equals(map[r][c], WALL)) {
            System.out.println(YES);
        } else {
            System.out.println(NO);
        }
        
    }
}

結果

image.png

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