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

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

int main() {
	int k;
	scanf("%d", &k);
	int A[] = { 1, 3, 5, 4, 6, 2, 1, 7, 1, 5 };
	printf("%d\n", A[k-1]);
	return 0;
}
```
###### STEP: 2
```c
#include <stdio.h>

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

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

int main() {
	int k;
	cin >> k;
	int A[] = { 1, 3, 5, 4, 6, 2, 1, 7, 1, 5 };
	cout << A[k-1] << endl;
	return 0;
}
```
###### STEP: 2
```cpp
#include <iostream>
using namespace std;

int main() {
	int n = 10;
	int k;
	cin >> k;
	int A[n];
	for (int &a : A) cin >> a;
	cout << A[k-1] << endl;
	return 0;
}
```
###### STEP: 3
```cpp
#include <iostream>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int A[n];
	for (int &a : A) cin >> a;
	cout << A[k-1] << endl;
	return 0;
}
```
- - -
##### C#
###### STEP: 1
```cs
using System;

class Program
{
	public static void Main()
	{
		int k = int.Parse(Console.ReadLine());
		int[] A = { 1, 3, 5, 4, 6, 2, 1, 7, 1, 5 };
		Console.WriteLine(A[k-1]);
	}
}
```
###### STEP: 2
```cs
using System;

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

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

func main() {
	var k int
	fmt.Scan(&k)
	A := []int{ 1, 3, 5, 4, 6, 2, 1, 7, 1, 5 }
	fmt.Println(A[k-1])
}
```
###### STEP: 2
```go
package main
import "fmt"

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}
	fmt.Println(A[k-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();
		sc.close();
		int[] A = { 1, 3, 5, 4, 6, 2, 1, 7, 1, 5 };
		System.out.println(A[k-1]);
	}
}
```
###### STEP: 2
```java
import java.util.*;

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

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

object Main extends App{
	val k = readInt()
	val A = Array(1, 3, 5, 4, 6, 2, 1, 7, 1, 5)
	println(A(k-1))
}
```
###### STEP: 2
```scala
import scala.io.StdIn._

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

object Main extends App{
	val k = readLine().split(' ')(1).toInt
	val A = readLine().split(' ').map { _.toInt }
	println(A(k-1))
}
```
- - -
##### Swift
###### STEP: 1
```swift
let k = Int(readLine()!)!
let A = [1, 3, 5, 4, 6, 2, 1, 7, 1, 5]
print(A[k-1])
```
###### STEP: 2
```swift
let k = Int(readLine()!)!
let A = readLine()!.split(separator: " ").compactMap { Int($0) }
print(A[k-1])
```
###### STEP: 3
```swift
let k = Int(readLine()!.split(separator: " ")[1])!
let A = readLine()!.split(separator: " ").compactMap { Int($0) }
print(A[k-1])
```