paizaラーニングレベルアップ問題集の「i番目の出力」をやってみた。～文字列配列～

paizaラーニングレベルアップ問題集の「$i$番目の出力」をやってみました。
- - -
##### 問題
###### STEP: 1
https://paiza.jp/works/mondai/array_primer/array_primer__string_i-thinput_step1
###### STEP: 2
https://paiza.jp/works/mondai/array_primer/array_primer__string_i-thinput_step2
###### STEP: 3
https://paiza.jp/works/mondai/array_primer/array_primer__string_i-thinput_step3
###### STEP: 4
https://paiza.jp/works/mondai/array_primer/array_primer__string_i-thinput_step4
- - -
##### C
###### STEP: 1
```c
#include <stdio.h>

const char *S[] = { "good", "morning", "paiza", "813", "pa13" };

int main() {
	int n;
	scanf("%d", &n);
	puts(S[n-1]);
	return 0;
}
```
###### STEP: 2
```c
#include <stdio.h>

const int M = 5;

int main() {
	int n;
	scanf("%d", &n);
	char s[M][11];
	for (int i = 0; i < M; i++) scanf("%s", s[i]);
	puts(s[n-1]);
	return 0;
}
```
###### STEP: 3
```c
#include <stdio.h>

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	char s[m][11];
	for (int i = 0; i < m; i++) scanf("%s", s[i]);
	puts(s[n-1]);
	return 0;
}
```
###### STEP: 4
```c
#include <stdio.h>

int main() {
	int n, m, l;
	scanf("%d %d %d", &n, &m, &l);
	char s[m][11];
	for (int i = 0; i < m; i++) scanf("%s", s[i]);
	putchar(s[n-1][l-1]);
	return 0;
}
```
- - -
##### C++
###### STEP: 1
```cpp
#include <iostream>
#include <vector>
using namespace std;

const vector<string> S = { "good", "morning", "paiza", "813", "pa13" };

int main() {
	int n;
	cin >> n;
	cout << S[n-1] << endl;
	return 0;
}
```
###### STEP: 2
```cpp
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> S;
	string s;
	cin >> s;
	while (!cin.fail()) {
		S.push_back(s);
		cin >> s;
	}
	cout << S[n-1] << endl;
	return 0;
}
```
###### STEP: 3
```cpp
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> S(m);
	for (int i = 0; i < m; i++) cin >> S[i];
	cout << S[n-1] << endl;
	return 0;
}
```
###### STEP: 4
```cpp
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	vector<string> S(m);
	for (int i = 0; i < m; i++) cin >> S[i];
	cout << S[n-1][l-1] << endl;
	return 0;
}
```
- - -
##### C#
###### STEP: 1
```cs
using System;

class Program
{
	static readonly string[] S = { "good", "morning", "paiza", "813", "pa13" };
	
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		Console.WriteLine(S[n-1]);
	}
}
```
###### STEP: 2
```cs
using System;

class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		string[] S = Console.ReadLine().Split();
		Console.WriteLine(S[n-1]);
	}
}
```
###### STEP: 3
```cs
using System;

class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine().Split()[0]);
		string[] S = Console.ReadLine().Split();
		Console.WriteLine(S[n-1]);
	}
}
```
###### STEP: 4
```cs
using System;

class Program
{
	public static void Main()
	{
		int nml = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int n = nml[0], l = nml[2];
		string[] S = Console.ReadLine().Split();
		Console.WriteLine(S[n-1][l-1]);
	}
}
```
- - -
##### Go
###### STEP: 1
```go
package main
import "fmt"

var S = []string{ "good", "morning", "paiza", "813", "pa13" }

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(S[n-1])
}
```
###### STEP: 2
```go
package main
import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	S := make([]string, 0)
	var s string
	for _, err := fmt.Scan(&s); err == nil; _, err = fmt.Scan(&s) {
		S = append(S, s)
	}
	fmt.Println(S[n-1])
}
```
###### STEP: 3
```go
package main
import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	S := make([]string, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&S[i])
	}
	fmt.Println(S[n-1])
}
```
###### STEP: 4
```go
package main
import "fmt"

func main() {
	var n, m, l int
	fmt.Scan(&n, &m, &l)
	S := make([]string, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&S[i])
	}
	fmt.Printf("%c\n", S[n-1][l-1])
}
```
- - -
##### Java
###### STEP: 1
```java
import java.util.*;

public class Main {

	static final String[] S = { "good", "morning", "paiza", "813", "pa13" };
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		System.out.println(S[n-1]);
	}
}
```
###### STEP: 2
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] S = sc.nextLine().split(" ");
		sc.close();
		System.out.println(S[n-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();
		sc.nextLine();
		String[] S = sc.nextLine().split(" ");
		sc.close();
		System.out.println(S[n-1]);
	}
}
```
###### STEP: 4
```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 l = sc.nextInt();
		sc.nextLine();
		String[] S = sc.nextLine().split(" ");
		sc.close();
		System.out.println(S[n-1].toCharArray()[l-1]);
	}
}
```
- - -
##### JavaScript
###### STEP: 1
```js
const S = ["good", "morning", "paiza", "813", "pa13"];
const n = Number(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(S[n-1]);
```
###### STEP: 2
```js
const [n, S] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map((s, i) => i ? s.split(' ') : Number(s));
console.log(S[n-1]);
```
###### STEP: 3
```js
const [[n, m], S] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map((s, i) => i ? s.split(' ') : s.split(' ').map(Number));
console.log(S[n-1]);
```
###### STEP: 4
```js
const [[n, m, l], S] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map((s, i) => i ? s.split(' ') : s.split(' ').map(Number));
console.log(S[n-1][l-1]);
```
- - -
##### Kotlin
###### STEP: 1
```kotlin
fun main() {
	val S = arrayOf("good", "morning", "paiza", "813", "pa13")
	val n = readLine()!!.toInt()
	println(S[n-1])
}
```
###### STEP: 2
```kotlin
fun main() {
	val n = readLine()!!.toInt()
	val S = readLine()!!.split(' ')
	println(S[n-1])
}
```
###### STEP: 3
```kotlin
fun main() {
	val (n, _) = readLine()!!.split(' ').map { it.toInt() }
	val S = readLine()!!.split(' ')
	println(S[n-1])
}
```
###### STEP: 4
```kotlin
fun main() {
	val (n, _, l) = readLine()!!.split(' ').map { it.toInt() }
	val S = readLine()!!.split(' ')
	println(S[n-1][l-1])
}
```
- - -
##### PHP
###### STEP: 1
```php
<?php
	$S = ["good", "morning", "paiza", "813", "pa13"];
	$n = intval(fgets(STDIN));
	echo $S[$n-1], PHP_EOL;
?>
```
###### STEP: 2
```php
<?php
	$n = intval(fgets(STDIN));
	$S = explode(' ', trim(fgets(STDIN)));
	echo $S[$n-1], PHP_EOL;
?>
```
###### STEP: 3
```php
<?php
	[$n, $m] = array_map("intval", explode(' ', fgets(STDIN)));
	$S = explode(' ', trim(fgets(STDIN)));
	echo $S[$n-1], PHP_EOL;
?>
```
###### STEP: 4
```php
<?php
	[$n, $m, $l] = array_map("intval", explode(' ', fgets(STDIN)));
	$S = explode(' ', trim(fgets(STDIN)));
	echo $S[$n-1][$l-1], PHP_EOL;
?>
```
- - -
##### Perl
###### STEP: 1
```pl
my @S = ("good", "morning", "paiza", "813", "pa13");
my $n = int(<STDIN>);
print "$S[$n-1]$/";
```
###### STEP: 2
```pl
my $n = int(<STDIN>);
my @S = split ' ', <STDIN>;
print "$S[$n-1]$/";
```
###### STEP: 3
```pl
my ($n, $m) = map { int($_) } split ' ', <STDIN>;
my @S = split ' ', <STDIN>;
print "$S[$n-1]$/";
```
###### STEP: 4
```pl
my ($n, $m, $l) = map { int($_) } split ' ', <STDIN>;
my @S = split ' ', <STDIN>;
print substr($S[$n-1], $l-1, 1), $/;
```
- - -
##### Python3
###### STEP: 1
```py
S = ["good", "morning", "paiza", "813", "pa13"]
n = int(input())
print(S[n-1])
```
###### STEP: 2
```py
n = int(input())
S = input().split()
print(S[n-1])
```
###### STEP: 3
```py
n, _ = map(int, input().split())
S = input().split()
print(S[n-1])
```
###### STEP: 4
```py
n, _, l = map(int, input().split())
S = input().split()
print(S[n-1][l-1])
```
- - -
##### Ruby
###### STEP: 1
```rb
S = ["good", "morning", "paiza", "813", "pa13"]
n = gets.to_i
puts S[n-1]
```
###### STEP: 2
```rb
n = gets.to_i
S = gets.split
puts S[n-1]
```
###### STEP: 3
```rb
n, _ = gets.split.map(&:to_i)
S = gets.split
puts S[n-1]
```
###### STEP: 4
```rb
n, _, l = gets.split.map(&:to_i)
S = gets.split
puts S[n-1][l-1]
```
- - -
##### Scala
###### STEP: 1
```scala
import scala.io.StdIn._

object Main extends App{
	val S = Array("good", "morning", "paiza", "813", "pa13")
	val n = readInt()
	println(S(n-1))
}
```
###### STEP: 2
```scala
import scala.io.StdIn._

object Main extends App{
	val n = readInt()
	val S = readLine().split(' ')
	println(S(n-1))
}
```
###### STEP: 3
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(n, m) = readLine().split(' ').map { _.toInt }
	val S = readLine().split(' ')
	println(S(n-1))
}
```
###### STEP: 4
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(n, m, l) = readLine().split(' ').map { _.toInt }
	val S = readLine().split(' ')
	println(S(n-1)(l-1))
}
```
- - -
##### Swift
###### STEP: 1
```swift
let S = ["good", "morning", "paiza", "813", "pa13"]
let n = Int(readLine()!)!
print(S[n-1])
```
###### STEP: 2
```swift
let n = Int(readLine()!)!
let S = readLine()!.split(separator: " ")
print(S[n-1])
```
###### STEP: 3
```swift
let n = Int(readLine()!.split(separator: " ")[0])!
let S = readLine()!.split(separator: " ")
print(S[n-1])
```
###### STEP: 4
```swift
let nml = readLine()!.split(separator: " ").compactMap { Int($0) }
let (n, l) = (nml[0], nml[2])
let S = readLine()!.split(separator: " ")
let s = S[n-1]
print(s[s.index(s.startIndex, offsetBy: l-1)])
```