paizaラーニングレベルアップ問題集の【二次元配列の入出力】「i番目の出力」をやってみた。

paizaラーニングレベルアップ問題集の【二次元配列の入出力】「$i$番目の出力」をやってみました。
- - -
##### 問題
###### STEP: 1
https://paiza.jp/works/mondai/array_primer/array_primer__2dmatrix_i-thoutput_step1
###### STEP: 2
https://paiza.jp/works/mondai/array_primer/array_primer__2dmatrix_i-thoutput_step2
###### STEP: 3
https://paiza.jp/works/mondai/array_primer/array_primer__2dmatrix_i-thoutput_boss
- - -
$K$と$L$は、入力した時点または直後で$1$引いておくのがいいかも（以下サンプルでは出力時に`1`引いております）。
- - -
##### C
###### STEP: 1
```c
#include <stdio.h>
#define N (4)
#define M (4)

int main() {
	int K, L;
	scanf("%d %d", &K, &L);
	int A[N][M] = { { 1, 2, 3, 4 }, { 10, 100, 0, 5 }, { 8, 1, 3, 8 }, { 15, 34, 94, 25 } };
	printf("%d\n", A[K-1][L-1]);
	return 0;
}
```
###### STEP: 2
```c
#include <stdio.h>

int main() {
	int N = 3;
	int M = 3;
	int K, L;
	scanf("%d %d", &K, &L);
	int A[N][M];
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			scanf("%d", &A[i][j]);
	printf("%d\n", A[K-1][L-1]);
	return 0;
}
```
###### STEP: 3
```c
#include <stdio.h>

int main() {
	int N, M, K, L;
	scanf("%d %d %d %d", &N, &M, &K, &L);
	int A[N][M];
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			scanf("%d", &A[i][j]);
	printf("%d\n", A[K-1][L-1]);
	return 0;
}
```
- - -
##### C++
###### STEP: 1
```cpp
#include <iostream>
using namespace std;

const int N = 4;
const int M = 4;

int main() {
	int K, L;
	cin >> K >> L;
	int A[N][M] = { { 1, 2, 3, 4 }, { 10, 100, 0, 5 }, { 8, 1, 3, 8 }, { 15, 34, 94, 25 } };
	cout << A[K-1][L-1] << endl;
	return 0;
}
```
###### STEP: 2
```cpp
#include <iostream>
using namespace std;

int main() {
	int N = 3;
	int M = 3;
	int K, L;
	cin >> K >> L;
	int A[N][M];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	cout << A[K-1][L-1] << endl;
	return 0;
}
```
###### STEP: 3
```cpp
#include <iostream>
using namespace std;

int main() {
	int N, M, K, L;
	cin >> N >> M >> K >> L;
	int A[N][M];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	cout << A[K-1][L-1] << endl;
	return 0;
}
```
- - -
##### C#
###### STEP: 1
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] kl = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int K = kl[0], L = kl[1];
		int[][] A = { new int[]{ 1, 2, 3, 4 }, new int[]{ 10, 100, 0, 5 }, new int[]{ 8, 1, 3, 8 }, new int[]{ 15, 34, 94, 25 } };
		Console.WriteLine(A[K-1][L-1]);
	}
}
```
###### STEP: 2
```cs
using System;

class Program
{
	public static void Main()
	{
		int N = 3;
		//int M = 3;
		int[] kl = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int K = kl[0], L = kl[1];
		int[][] A = new int[N][];
		for (int i = 0; i < N; i++) A[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		Console.WriteLine(A[K-1][L-1]);
	}
}
```
###### STEP: 3
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] nmkl = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int N = nmkl[0], K = nmkl[2], L = nmkl[3];
		int[][] A = new int[N][];
		for (int i = 0; i < N; i++) A[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		Console.WriteLine(A[K-1][L-1]);
	}
}
```
- - -
##### Go
###### STEP: 1
```go
package main
import "fmt"

func main() {
	var K, L int
	fmt.Scan(&K, &L)
	A := [][]int{ []int{ 1, 2, 3, 4 }, []int{ 10, 100, 0, 5 }, []int{ 8, 1, 3, 8 }, []int{ 15, 34, 94, 25 } }
	fmt.Println(A[K-1][L-1])
}
```
###### STEP: 2
```go
package main
import "fmt"

func main() {
	N := 3
	M := 3
	var K, L int
	fmt.Scan(&K, &L)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	fmt.Println(A[K-1][L-1])
}
```
###### STEP: 3
```go
package main
import "fmt"

func main() {
	var N, M, K, L int
	fmt.Scan(&N, &M, &K, &L)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	fmt.Println(A[K-1][L-1])
}
```
- - -
##### Java
###### STEP: 1
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int L = sc.nextInt();
		int[][] A = { { 1, 2, 3, 4 }, { 10, 100, 0, 5 }, { 8, 1, 3, 8 }, { 15, 34, 94, 25 } };
		sc.close();
		System.out.println(A[K-1][L-1]);
	}
}
```
###### STEP: 2
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = 3;
		//int M = 3;
		int K = sc.nextInt();
		int L = sc.nextInt();
		sc.nextLine();
		int[][] A = new int[N][];
		for (int i = 0; i < N; i++) A[i] = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		sc.close();
		System.out.println(A[K-1][L-1]);
	}
}
```
###### STEP: 3
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		int L = sc.nextInt();
		sc.nextLine();
		int[][] A = new int[N][];
		for (int i = 0; i < N; i++) A[i] = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		sc.close();
		System.out.println(A[K-1][L-1]);
	}
}
```
- - -
##### JavaScript
###### STEP: 1
```js
const [K, L] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
const A = [ [ 1, 2, 3, 4 ], [ 10, 100, 0, 5 ], [ 8, 1, 3, 8 ], [ 15, 34, 94, 25 ]];
console.log(A[K-1][L-1]);
```
###### STEP: 2
```js
const [[K, L], ...A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map(s => s.split(' ').map(Number));
console.log(A[K-1][L-1]);
```
###### STEP: 3
```js
const [[N, M, K, L], ...A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map(s => s.split(' ').map(Number));
console.log(A[K-1][L-1]);
```
- - -
##### Kotlin
###### STEP: 1
```kotlin
fun main() {
	val (K, L) = readLine()!!.split(' ').map { it.toInt() }
	val A = arrayOf(arrayOf(1, 2, 3, 4), arrayOf(10, 100, 0, 5), arrayOf(8, 1, 3, 8), arrayOf(15, 34, 94, 25))
	println(A[K-1][L-1])
}
```
###### STEP: 2
```kotlin
fun main() {
	val N = 3
	val (K, L) = readLine()!!.split(' ').map { it.toInt() }
	val A = Array(N) { readLine()!!.split(' ').map { it.toInt() } }
	println(A[K-1][L-1])
}
```
###### STEP: 3
```kotlin
fun main() {
	val (N, _, K, L) = readLine()!!.split(' ').map { it.toInt() }
	val A = Array(N) { readLine()!!.split(' ').map { it.toInt() } }
	println(A[K-1][L-1])
}
```
- - -
##### PHP
###### STEP: 1
```php
<?php
	[$K, $L] = array_map("intval", explode(' ', fgets(STDIN)));
	$A = [ [ 1, 2, 3, 4 ], [ 10, 100, 0, 5 ], [ 8, 1, 3, 8 ], [ 15, 34, 94, 25 ] ]; 
	echo $A[$K-1][$L-1], PHP_EOL;
?>
```
###### STEP: 2
```php
<?php
	$N = 3;
	[$K, $L] = array_map("intval", explode(' ', fgets(STDIN)));
	$A = []; 
	for ($i = 0; $i < $N; $i++) $A[] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $A[$K-1][$L-1], PHP_EOL;
?>
```
###### STEP: 3
```php
<?php
	[$N, $M, $K, $L] = array_map("intval", explode(' ', fgets(STDIN)));
	$A = []; 
	for ($i = 0; $i < $N; $i++) $A[] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $A[$K-1][$L-1], PHP_EOL;
?>
```
- - -
##### Perl
###### STEP: 1
```pl
my ($K, $L) = map { int($_) } split ' ', <STDIN>;
my @A = ( [ 1, 2, 3, 4 ], [ 10, 100, 0, 5 ], [ 8, 1, 3, 8 ], [ 15, 34, 94, 25 ] );
print $A[$K-1][$L-1], $/;
```
###### STEP: 2
```pl
my $N = 3;
my ($K, $L) = map { int($_) } split ' ', <STDIN>;
my @A;
for (1..$N) {
	push @A, [map { int($_) } split ' ', <STDIN>];
}
print $A[$K-1][$L-1], $/;
```
###### STEP: 3
```pl
my ($N, $M, $K, $L) = map { int($_) } split ' ', <STDIN>;
my @A;
for (1..$N) {
	push @A, [map { int($_) } split ' ', <STDIN>];
}
print $A[$K-1][$L-1], $/;
```
- - -
##### Python3
###### STEP: 1
```py
K, L = map(int, input().split())
A = [ [ 1, 2, 3, 4 ], [ 10, 100, 0, 5 ], [ 8, 1, 3, 8 ], [ 15, 34, 94, 25 ] ]
print(A[K-1][L-1])
```
###### STEP: 2
```py
N = 3
K, L = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
print(A[K-1][L-1])
```
###### STEP: 3
```py
N, M, K, L = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
print(A[K-1][L-1])
```
- - -
##### Ruby
###### STEP: 1
```rb
K, L = gets.split.map(&:to_i)
A = [ [ 1, 2, 3, 4 ], [ 10, 100, 0, 5 ], [ 8, 1, 3, 8 ], [ 15, 34, 94, 25 ] ]
p A[K-1][L-1]
```
###### STEP: 2
```rb
N = 3
K, L = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }
p A[K-1][L-1]
```
###### STEP: 3
```rb
N, M, K, L = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }
p A[K-1][L-1]
```
- - -
##### Scala
###### STEP: 1
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(k, l) = readLine().split(' ').map { _.toInt }
	val A = Array(Array(1, 2, 3, 4), Array(10, 100, 0, 5), Array(8, 1, 3, 8), Array(15, 34, 94, 25))
	println(A(k-1)(l-1))
}
```
###### STEP: 2
```scala
import scala.io.StdIn._

object Main extends App{
	val N = 3
	val Array(k, l) = readLine().split(' ').map { _.toInt }
	val A = Array.fill(N) { readLine().split(' ').map { _.toInt } }
	println(A(k-1)(l-1))
}
```
###### STEP: 3
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(n, _, k, l) = readLine().split(' ').map { _.toInt }
	val A = Array.fill(n) { readLine().split(' ').map { _.toInt } }
	println(A(k-1)(l-1))
}
```
- - -
##### Swift
###### STEP: 1
```swift
let kl = readLine()!.split(separator: " ").compactMap { Int($0) }
let (K, L) = (kl[0], kl[1])
let A = [ [ 1, 2, 3, 4 ], [ 10, 100, 0, 5 ], [ 8, 1, 3, 8 ], [ 15, 34, 94, 25 ] ]
print(A[K-1][L-1])
```
###### STEP: 2
```swift
let N = 3
let kl = readLine()!.split(separator: " ").compactMap { Int($0) }
let (K, L) = (kl[0], kl[1])
var A: [[Int]] = []
for _ in 0..<N {
	A.append(readLine()!.split(separator: " ").compactMap { Int($0) })
}
print(A[K-1][L-1])
```
###### STEP: 3
```swift
let nmkl = readLine()!.split(separator: " ").compactMap { Int($0) }
let (N, K, L) = (nmkl[0], nmkl[2], nmkl[3])
var A: [[Int]] = []
for _ in 0..<N {
	A.append(readLine()!.split(separator: " ").compactMap { Int($0) })
}
print(A[K-1][L-1])
```