paizaラーニングレベルアップ問題集の「配列の入力」をやってみた。

paizaラーニングレベルアップ問題集の「配列の入力」をやってみました。
- - -
##### 問題
###### STEP: 1
https://paiza.jp/works/mondai/array_primer/array_primer__1dmatrix_input_step1
###### STEP: 2
https://paiza.jp/works/mondai/array_primer/array_primer__1dmatrix_input_step2
###### STEP: 3
https://paiza.jp/works/mondai/array_primer/array_primer__1dmatrix_input_step3
- - -
##### C
###### STEP: 1
```c
#include <stdio.h>

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

const int N = 10;

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

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

int main() {
	int A[] = {8, 1, 3, 3, 8, 1, 1, 3, 8, 8};
	for (int a : A) cout << a << endl;
	return 0;
}
```
###### STEP: 2
```cpp
#include <iostream>
using namespace std;

const int N = 10;

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

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

class Program
{
	public static void Main()
	{
		int[] A = {8, 1, 3, 3, 8, 1, 1, 3, 8, 8};
		foreach (int a in A) Console.WriteLine(a);
	}
}
```
###### STEP: 2
```cs
using System;

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

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

func main() {
	A := []int{ 8, 1, 3, 3, 8, 1, 1, 3, 8, 8 }
	for _, a := range(A) {
		fmt.Println(a)
	}
}
```
###### STEP: 2
```go
package main
import "fmt"

const N = 10

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

func main() {
	var n int
	fmt.Scan(&n)
	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}
	for i := 0; i < n; i++ {
		fmt.Println(A[i])
	}
}
```
- - -
##### Java
###### STEP: 1
```java
public class Main {
	public static void main(String[] args) {
		int[] A = {8, 1, 3, 3, 8, 1, 1, 3, 8, 8};
		for (int a : A) System.out.println(a);
	}
}
```
###### STEP: 2
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		sc.close();
		for (int a : A) System.out.println(a);
	}
}
```
###### 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();
		sc.nextLine();
		int[] A = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		sc.close();
		for (int i = 0; i < n; i++) System.out.println(A[i]);
	}
}
```
- - -
##### JavaScript
###### STEP: 1
```js
const A = [8, 1, 3, 3, 8, 1, 1, 3, 8, 8];
A.forEach(a => console.log(a));
```
###### STEP: 2
```js
const A = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
A.forEach(a => console.log(a));
```
###### STEP: 3
```js
const [N, A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map((s, i) => i ? s.split(' ').map(Number) : Number(s));
for (var i = 0; i < N; i++) console.log(A[i]);
```
- - -
##### Kotlin
###### STEP: 1
```kotlin
fun main() {
	val A = arrayOf(8, 1, 3, 3, 8, 1, 1, 3, 8, 8)
	for (a in A) println(a)
}
```
###### STEP: 2
```kotlin
fun main() {
	val A = readLine()!!.split(' ').map { it.toInt() }
	for (a in A) println(a)
}
```
###### STEP: 3
```kotlin
fun main() {
	val n = readLine()!!.toInt()
	val A = readLine()!!.split(' ').map { it.toInt() }
	for (i in 0 until n) println(A[i])
}
```
- - -
##### PHP
###### STEP: 1
```php
<?php
	$A = [8, 1, 3, 3, 8, 1, 1, 3, 8, 8];
	foreach ($A as $a) echo $a, PHP_EOL;
?>
```
###### STEP: 2
```php
<?php
	$A = array_map("intval", explode(' ', fgets(STDIN)));
	foreach ($A as $a) echo $a, PHP_EOL;
?>
```
###### STEP: 3
```php
<?php
	$N = intval(fgets(STDIN));
	$A = array_map("intval", explode(' ', fgets(STDIN)));
	for ($i = 0; $i < $N; $i++) echo $A[$i], PHP_EOL;
?>
```
- - -
##### Perl
###### STEP: 1
```pl
my @A = (8, 1, 3, 3, 8, 1, 1, 3, 8, 8);
for (@A) {
	print "$_$/";
}
```
###### STEP: 2
```pl
my @A = map { int($_) } split ' ', <STDIN>;
for (@A) {
	print "$_$/";
}
```
###### STEP: 3
```pl
my $n = int(<STDIN>);
my @A = map { int($_) } split ' ', <STDIN>;
for (my $i = 0; $i < $n; $i++) {
	print $A[$i], $/;
}
```
- - -
##### Python3
###### STEP: 1
```py
A = [8, 1, 3, 3, 8, 1, 1, 3, 8, 8]
for a in A:
	print(a)
```
###### STEP: 2
```py
A = list(map(int, input().split()))
for a in A:
	print(a)
```
###### STEP: 3
```py
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
	print(A[i])
```
- - -
##### Ruby
###### STEP: 1
```rb
A = [8, 1, 3, 3, 8, 1, 1, 3, 8, 8]
A.each do |a|
	p a
end
```
###### STEP: 2
```rb
A = gets.split.map(&:to_i)
A.each do |a|
	p a
end
```
###### STEP: 3
```rb
N = gets.to_i
A = gets.split.map(&:to_i)
N.times do |i|
	p A[i]
end
```
- - -
##### Scala
###### STEP: 1
```scala
object Main extends App{
	val A = Array(8, 1, 3, 3, 8, 1, 1, 3, 8, 8)
	for (a <- A) println(a)
}
```
###### STEP: 2
```scala
import scala.io.StdIn._

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

object Main extends App{
	val N = readInt()
	val A = readLine().split(' ').map { _.toInt }
	for (i <- 0 until N) println(A(i))
}
```
- - -
##### Swift
###### STEP: 1
```swift
let A = [8, 1, 3, 3, 8, 1, 1, 3, 8, 8]
for a in A {
	print(a)
}
```
###### STEP: 2
```swift
let A = readLine()!.split(separator: " ").compactMap { Int($0) }
for a in A {
	print(a)
}
```
###### STEP: 3
```swift
let N = Int(readLine()!)!
let A = readLine()!.split(separator: " ").compactMap { Int($0) }
for i in 0..<N {
	print(A[i])
}
```