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

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

const char *S[] = { "eight", "one", "three", "paiza", "pa13", "813" };

int main() {
	int n = (int) (sizeof(S) / sizeof(S[0]));
	for (int i = 0; i < n; i++) puts(S[i]);
	return 0;
}
```
###### STEP: 2
```c
#include <stdio.h>

const int N = 10;

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

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

const vector<string> S = { "eight", "one", "three", "paiza", "pa13", "813" };

int main() {
	for (string s : S) cout << s << endl;
	return 0;
}
```
###### STEP: 2
```cpp
#include <iostream>
#include <vector>
using namespace std;

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

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

class Program
{
	static readonly string[] S = { "eight", "one", "three", "paiza", "pa13", "813" };

	public static void Main()
	{
		foreach (string s in S) Console.WriteLine(s);
	}
}
```
###### STEP: 2
```cs
using System;

class Program
{
	public static void Main()
	{
		string[] S = Console.ReadLine().Split();
		foreach (string s in S) Console.WriteLine(s);
	}
}
```
###### STEP: 3
```cs
using System;

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

var S = []string{ "eight", "one", "three", "paiza", "pa13", "813" }

func main() {
	for _, s := range(S) {
		fmt.Println(s)
	}
}
```
###### STEP: 2
```go
package main
import "fmt"

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

func main() {
	var n int
	fmt.Scan(&n)
	S := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&S[i])
	}
	for _, s := range(S) {
		fmt.Println(s)
	}
}
```
- - -
##### Java
###### STEP: 1
```java
public class Main {

	private static final String[] S = { "eight", "one", "three", "paiza", "pa13", "813" };
	
	public static void main(String[] args) {
		for (String s : S) System.out.println(s);
	}
}
```
###### STEP: 2
```java
import java.util.*;

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

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

object Main extends App{
	val n = readInt()
	val S = readLine().split(' ')
	for (i <- 0 until n) println(S(i))
}
```
- - -
##### Swift
###### STEP: 1
```swift
let S = ["eight", "one", "three", "paiza", "pa13", "813"]
for s in S {
	print(s)
}
```
###### STEP: 2
```swift
let S = readLine()!.split(separator: " ")
for s in S {
	print(s)
}
```
###### STEP: 3
```swift
let n = Int(readLine()!)!
let S = readLine()!.split(separator: " ")
for i in 0..<n {
	print(S[i])
}
```