paizaラーニングレベルアップ問題集の【配列メニュー】をやってみた。(14)～文字列配列～

paizaラーニングレベルアップ問題集の【配列メニュー】をやってみました。
- - -
##### 問題
###### 要素数の出力
https://paiza.jp/works/mondai/array_primer/array_primer__string_output_step1
###### 全要素の出力
https://paiza.jp/works/mondai/array_primer/array_primer__string_output_step2
###### i番目の出力
https://paiza.jp/works/mondai/array_primer/array_primer__string_output_step3
- - -
##### C
###### 要素数の出力
```c
#include <stdio.h>

const char* S[] = {"Hello", "paiza", "1234", "pa13"};

int main() {
	printf("%zu\n", sizeof(S) / sizeof(S[0]));
	return 0;
}
```
###### 全要素の出力
```c
#include <stdio.h>

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

int main() {
	int n = (int) (sizeof(S) / sizeof(S[0]));
	for (int i = 0; i < n; i++) puts(S[i]);
	return 0;
}
```
###### i番目の出力
```c
#include <stdio.h>

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

int main() {
	puts(S[2]);
	return 0;
}
```
- - -
##### C++
###### 要素数の出力
```cpp
#include <iostream>
#include <vector>
using namespace std;

const vector<string> S = {"Hello", "paiza", "1234", "pa13"};

int main() {
	cout << S.size() << endl;
	return 0;
}
```
###### 全要素の出力
```cpp
#include <iostream>
#include <vector>
using namespace std;

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

int main() {
	for (string s : S) cout << s << endl;
	return 0;
}
```
###### i番目の出力
```cpp
#include <iostream>
#include <vector>
using namespace std;

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

int main() {
	cout << S[2] << endl;
	return 0;
}
```
- - -
##### C#
###### 要素数の出力
```cs
using System;

class Program
{
	static readonly string[] S = {"Hello", "paiza", "1234", "pa13"};
	
	public static void Main()
	{
		Console.WriteLine(S.Length);
	}
}
```
###### 全要素の出力
```cs
using System;

class Program
{
	static readonly string[] S = {"good", "morning", "paiza", "813", "pa13"};
	
	public static void Main()
	{
		foreach (string s in S) Console.WriteLine(s);
	}
}
```
###### i番目の出力
```cs
using System;

class Program
{
	static readonly string[] S = {"good", "morning", "paiza", "813", "pa13"};

	public static void Main()
	{
		Console.WriteLine(S[2]);
	}
}
```
- - -
##### Go
###### 要素数の出力
```go
package main
import "fmt"

var S = []string{"Hello", "paiza", "1234", "pa13"}

func main() {
	fmt.Println(len(S))
}
```
###### 全要素の出力
```go
package main
import "fmt"

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

func main() {
	for _, s := range(S) {
		fmt.Println(s)
	}
}
```
###### i番目の出力
```go
package main
import "fmt"

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

func main() {
	fmt.Println(S[2])
}
```
- - -
##### Java
###### 要素数の出力
```java
public class Main {

	static final String[] S = {"Hello", "paiza", "1234", "pa13"};
	
	public static void main(String[] args) {
		System.out.println(S.length);
	}
}
```
###### 全要素の出力
```java
import java.util.*;

public class Main {

	static final String[] S = {"good", "morning", "paiza", "813", "pa13"};
	
	public static void main(String[] args) {
		for (String s : S) System.out.println(s);
	}
}
```
###### i番目の出力
```java
public class Main {

	static final String[] S = {"good", "morning", "paiza", "813", "pa13"};
	
	public static void main(String[] args) {
		System.out.println(S[2]);
	}
}
```
- - -
##### JavaScript
###### 要素数の出力
```js
S = ["Hello", "paiza", "1234", "pa13"];
console.log(S.length);
```
###### 全要素の出力
```js
S = ["good", "morning", "paiza", "813", "pa13"];
S.forEach(s => console.log(s));
```
###### i番目の出力
```js
S = ["good", "morning", "paiza", "813", "pa13"];
console.log(S[2]);
```
- - -
##### Kotlin
###### 要素数の出力
```kotlin
fun main() {
	val S = arrayOf("Hello", "paiza", "1234", "pa13")
	println(S.size)
	// println(S.count()) # 別解
}
```
###### 全要素の出力
```kotlin
fun main() {
	val S = arrayOf("good", "morning", "paiza", "813", "pa13")
	for (s in S) println(s)
}
```
###### i番目の出力
```kotlin
fun main() {
	val S = arrayOf("good", "morning", "paiza", "813", "pa13")
	println(S[2])
}
```
- - -
##### PHP
###### 要素数の出力
```php
<?php
	$S = ["Hello", "paiza", "1234", "pa13"];
	echo count($S), PHP_EOL;
?>
```
###### 全要素の出力
```php
<?php
	$S = ["good", "morning", "paiza", "813", "pa13"];
	foreach ($S as $s) echo $s, PHP_EOL;
?>
```
###### i番目の出力
```php
<?php
	$S = ["good", "morning", "paiza", "813", "pa13"];
	echo $S[2], PHP_EOL;
?>
```
- - -
##### Perl
###### 要素数の出力
```pl
my @S = ("Hello", "paiza", "1234", "pa13");
print scalar(@S), "$/";
```
###### 全要素の出力
```pl
my @S = ("good", "morning", "paiza", "813", "pa13");
for (@S) {
	print "$_$/"
}
```
###### i番目の出力
```pl
my @S = ("good", "morning", "paiza", "813", "pa13");
print $S[2], $/;
```
- - -
##### Python3
###### 要素数の出力
```py
S = ["Hello", "paiza", "1234", "pa13"]
print(len(S))
```
###### 全要素の出力
```py
S = ["good", "morning", "paiza", "813", "pa13"]
for s in S:
	print(s)
```
###### i番目の出力
```py
S = ["good", "morning", "paiza", "813", "pa13"]
print(S[2])
```
- - -
##### Ruby
###### 要素数の出力
```rb
S = ["Hello", "paiza", "1234", "pa13"]
# 以下、どれでも正解
p S.size
p S.count
p S.length
```
###### 全要素の出力
```rb
S = ["good", "morning", "paiza", "813", "pa13"]
S.each do |s|
	puts s
end
```
###### i番目の出力
```rb
S = ["good", "morning", "paiza", "813", "pa13"]
puts S[2]
```
- - -
##### Scala
###### 要素数の出力
```scala
object Main extends App{
	val S = Array("Hello", "paiza", "1234", "pa13")
	println(S.size)
	// println(S.length) # 別解
}
```
###### 全要素の出力
```scala
object Main extends App{
	val S = Array("good", "morning", "paiza", "813", "pa13")
	for (s <- S) println(s)
}
```
###### i番目の出力
```scala
object Main extends App{
	val S = Array("good", "morning", "paiza", "813", "pa13")
	println(S(2))
}
```
- - -
##### Swift
###### 要素数の出力
```swift
let S = ["Hello", "paiza", "1234", "pa13"]
print(S.count)
```
###### 全要素の出力
```swift
let S = ["good", "morning", "paiza", "813", "pa13"]
for s in S {
	print(s)
}
```
###### i番目の出力
```swift
let S = ["good", "morning", "paiza", "813", "pa13"]
print(S[2])
```