1
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?

More than 1 year has passed since last update.

paizaラーニング 解答【マップの扱い 1】マップの書き換え・1 マス Java編

Posted at

問題URL

もっと早いコードがあれば教えていただきたいです。

コード(Java)

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int row = sc.nextInt();
        int column = sc.nextInt();
        char[][] testList = new char[row][column];

        for (int i=0;i < row; i++) {
            String textVal = sc.next();
            for (int j=0;j < column; j++) {
                testList[i][j] = textVal.charAt(j);
            }
        }
        
        int y = sc.nextInt();
        int x = sc.nextInt();
        
        if(testList[y][x] == '.') {
            testList[y][x] = '#';
        } else if(testList[y][x] == '#') {
            testList[y][x] = '.';
        }

        for (int i=0;i < row; i++) {
        System.out.println(testList[i]);
        }
    }
}
1
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
1
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?