paizaラーニングレベルアップ問題集の【forループ】をやってみた。

paizaラーニングレベルアップ問題集のCランクレベルアップメニュー「forループ」をやってみました。
- - -
##### 問題
###### 3の倍数のカウント
https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_for_step1
###### フラグ管理
https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_for_step2
###### インデックス取得
https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_for_step3
###### 多重ループ
https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_for_step4
###### forループ
https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_for_boss
- - -
##### C
###### 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]);
	int cnt = 0;
	for (int i = 0; i < N; i++) cnt += A[i] % 3 == 0;
	printf("%d\n", cnt);
	return 0;
}
```
###### フラグ管理
```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]);
	int flg = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] == 7) {
			flg = 1;
			break;
		}
	}
	puts(flg ? "YES" : "NO");
	return 0;
}
```
###### インデックス取得
```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]);
	int k;
	scanf("%d", &k);
	for (int i = 0; i < N; i++) {
		if (A[i] == k) {
			printf("%d\n", i + 1);
			break;
		}
	}
	return 0;
}
```
###### 多重ループ
```c
#include <stdio.h>

int main() {
	int M;
	scanf("%d\n", &M);
	char C[M];
	for (int i = 0; i < M; i++) scanf("%c\n", &C[i]);
	int N;
	scanf("%d", &N);
	char S[N][11];
	for (int j = 0; j < N; j++) scanf("%s", S[j]);
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			int flg = 0;
			for (int k = 0; S[j][k]; k++) {
				if (S[j][k] == C[i]) {
					flg = 1;
					break;
				}
			}
			puts(flg ? "YES" : "NO");
		}
	}
	return 0;
}
```
###### forループ
```c
#include <stdio.h>

int main() {
	int N, M, K;
	scanf("%d %d %d", &N, &M, &K);
	int A[N][M];
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			scanf("%d", &A[i][j]);
	for (int i = 0; i < N; i++) {
		int cnt = 0;
		for (int j = 0; j < M; j++) cnt += A[i][j] == K;
		printf("%d\n", cnt);
	}
	return 0;
}
```
- - -
##### C++
###### 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];
	int cnt = 0;
	for (int i = 0; i < N; i++) cnt += A[i] % 3 == 0;
	cout << cnt << endl;
	return 0;
}
```
###### フラグ管理
```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];
	bool flg = false;
	for (int i = 0; i < N; i++) {
		if (A[i] == 7) {
			flg = true;
			break;
		}
	}
	cout << (flg ? "YES" : "NO") << endl;
	return 0;
}
```
###### インデックス取得
```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];
	int k;
	cin >> k;
	for (int i = 0; i < N; i++) {
		if (A[i] == k) {
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;
}
```
###### 多重ループ
```cpp
#include <iostream>
using namespace std;

int main() {
	int M;
	cin >> M;
	char C[M];
	for (int i = 0; i < M; i++) cin >> C[i];
	int N;
	cin >> N;
	string S[N];
	for (int j = 0; j < N; j++) cin >> S[j];
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			cout << (S[j].find(C[i]) == string::npos ? "NO" : "YES") << endl;
		}
	}
	return 0;
}
```
###### forループ
```cpp
#include <iostream>
using namespace std;

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	int A[N][M];
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			cin >> A[i][j];
	for (int i = 0; i < N; i++) {
		int cnt = 0;
		for (int j = 0; j < M; j++) cnt += A[i][j] == K;
		cout << cnt << endl;
	}
	return 0;
}
```
- - -
##### C#
###### 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);
		int cnt = 0;
		for (int i = 0; i < N; i++) if (A[i] % 3 == 0) cnt++;
		Console.WriteLine(cnt);
	}
}
```
###### フラグ管理
```cs
using System;

class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		int[] A = new int[N];
		for (int i = 0; i < N; i++) A[i] = int.Parse(Console.ReadLine());
		bool flg = false;
		for (int i = 0; i < N; i++) {
			if (A[i] == 7) {
				flg = true;
				break;
			}
		}
		Console.WriteLine(flg ? "YES" : "NO");
	}
}
```
###### インデックス取得
```cs
using System;

class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		int[] A = new int[N];
		for (int i = 0; i < N; i++) A[i] = int.Parse(Console.ReadLine());
		int k = int.Parse(Console.ReadLine());
		for (int i = 0; i < N; i++) {
			if (A[i] == k) {
				Console.WriteLine(i + 1);
				break;
			}
		}
	}
}
```
###### 多重ループ
```cs
using System;

class Program
{
	public static void Main()
	{
		int M = int.Parse(Console.ReadLine());
		char[] C = new char[M];
		for (int i = 0; i < M; i++) C[i] = Console.ReadLine()[0];
		int N = int.Parse(Console.ReadLine());
		string[] S = new string[N];
		for (int j = 0; j < N; j++) S[j] = Console.ReadLine();
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++) {
				Console.WriteLine(S[j].IndexOf(C[i]) == -1 ? "NO" : "YES");
			}
		}
	}
}
```
###### forループ
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] nmk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int N = nmk[0], M = nmk[1], K = nmk[2];
		int[][] A = new int[N][];
		for (int i = 0; i < N; i++) A[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		for (int i = 0; i < N; i++) {
			int cnt = 0;
			for (int j = 0; j < M; j++) if (A[i][j] == K) cnt++;
			Console.WriteLine(cnt);
		}
	}
}
```
- - -
##### Go
###### 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])
	}
	cnt := 0
	for i := 0; i < N; i++ {
		if (A[i] % 3 == 0) {
			cnt += 1
		}
	}
	fmt.Println(cnt)
}
```
###### フラグ管理
```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])
	}
	flg := true
	for i := 0; i < N; i++ {
		if A[i] == 7 {
			flg = true
			break
		}
	}
	if (flg) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
```
###### インデックス取得
```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])
	}
	var k int
	fmt.Scan(&k)
	for i := 0; i < N; i++ {
		if A[i] == k {
			fmt.Println(i + 1)
			break
		}
	}
}
```
###### 多重ループ
```go
package main
import "fmt"

func main() {
	var M int
	fmt.Scanf("%d\n", &M)
	C := make([]byte, M)
	for i := 0; i < M; i++ {
		var s string
		fmt.Scan(&s)
		C[i] = s[0]
	}
	var N int
	fmt.Scan(&N)
	S := make([]string, N)
	for j := 0; j < N; j++ {
		fmt.Scan(&S[j])
	}
	for i := 0; i < M; i++ {
		for j := 0; j < N; j++ {
			L := len(S[j])
			for k := 0; k <= L; k++ {
				if k == L {
					fmt.Println("NO")
				} else if S[j][k] == C[i] {
					fmt.Println("YES")
					break
				}
			}
		}
	}
}
```
###### forループ
```go
package main
import "fmt"

func main() {
	var N, M, K int
	fmt.Scan(&N, &M, &K)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	for i := 0; i < N; i++ {
		cnt := 0
		for j := 0; j < M; j++ {
			if A[i][j] == K {
				cnt += 1
			}
		}
		fmt.Println(cnt)
	}
}
```
- - -
##### Java
###### 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();
		int cnt = 0;
		for (int i = 0; i < N; i++) if (A[i] % 3 == 0) cnt++;
		System.out.println(cnt);
	}
}
```
###### フラグ管理
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) A[i] = sc.nextInt();
		sc.close();
		boolean flg = false;
		for (int i = 0; i < N; i++) {
			if (A[i] == 7) {
				flg = true;
				break;
			}
		}
		System.out.println(flg ? "YES" : "NO");
	}
}
```
###### インデックス取得
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) A[i] = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		for (int i = 0; i < N; i++) {
			if (A[i] == k) {
				System.out.println(i + 1);
				break;
			}
		}
	}
}
```
###### 多重ループ
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		char[] C = new char[M];
		for (int i = 0; i < M; i++) C[i] = sc.next().toCharArray()[0];
		int N = sc.nextInt();
		String[] S = new String[N];
		for (int j = 0; j < N; j++) S[j] = sc.next();
		sc.close();
		for (int i = 0; i < M; i++)
			for (int j = 0; j < N; j++)
				System.out.println(S[j].indexOf(C[i]) == -1 ? "NO" : "YES");
	}
}
```
###### forループ
```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 K = sc.nextInt();
		sc.nextLine();
		int[][] A = new int[N][];
		for (int i = 0; i < N; i++) A[i] = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		sc.close();
		for (int i = 0; i < N; i++) {
			int cnt = 0;
			for (int j = 0; j < M; j++) if (A[i][j] == K) cnt++;
			System.out.println(cnt);
		}
	}
}
```
- - -
##### JavaScript
###### 3の倍数のカウント
```js
const [N, A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map((s, i) => i ? s.split(' ').map(Number) : Number(s));
let cnt = 0;
for (var i = 0; i < N; i++) if (A[i] % 3 == 0) cnt++;
console.log(cnt);
```
###### フラグ管理
```js
const [N, ...A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map(Number);
let flg = false;
for (var i = 0; i < N; i++) {
	if (A[i] === 7) {
		flg = true;
		break;
	}
}
console.log(flg ? "YES" : "NO");
```
###### インデックス取得
```js
let [N, ...A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map(Number);
const k = A.pop();
for (var i = 0; i < N; i++) {
	if (A[i] === k) {
		console.log(i + 1);
		break;
	}
}
```
###### 多重ループ
```js
const S = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n');
const M = Number(S.shift());
let C = []
for (var i = 0; i < M; i++) C.push(S.shift()[0]);
const N = Number(S.shift());
for (var i = 0; i < M; i++) {
	for (var j = 0; j < N; j++) {
		console.log(S[j].indexOf(C[i]) + 1 ? "YES" : "NO");
	}
}
```
###### forループ
```js
const [[N, M, K], ...A] = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n').map(s => s.split(' ').map(Number));
for (var i = 0; i < N; i++) {
	let cnt = 0;
	for (var j = 0; j < M; j++) cnt += A[i][j] === K;
	console.log(cnt);
}
```
- - -
##### Kotlin
###### 3の倍数のカウント
```kotlin
fun main() {
	val N = readLine()!!.toInt()
	val A = readLine()!!.split(' ').map { it.toInt() }
	var cnt = 0
	for (i in 0 until N) if (A[i] % 3 == 0) cnt += 1
	println(cnt)
}
```
###### フラグ管理
```kotlin
fun main() {
	println(if (Array(readLine()!!.toInt()) { readLine()!!.toInt() }.any { it == 7 }) "YES" else "NO")
}
```
###### インデックス取得
```kotlin
fun main() {
	val N = readLine()!!.toInt()
	val A = Array(N) { readLine()!!.toInt() }
	val k = readLine()!!.toInt()
	for (i in 0 until N) {
		if (A[i] == k) {
			println(i + 1)
			break
		}
	}
}
```
###### 多重ループ
```kotlin
fun main() {
	val M = readLine()!!.toInt()
	val C = Array(M) { readLine()!![0] }
	val N = readLine()!!.toInt()
	val S = Array(N) { readLine()!! }
	for (i in 0 until M) {
		for (j in 0 until N) {
			println(if (S[j].indexOf(C[i]) == -1) "NO" else "YES")
		}
	}
}
```
###### forループ
```kotlin
fun main() {
	val (N, M, K) = readLine()!!.split(' ').map { it.toInt() }
	val A = Array(N) { readLine()!!.split(' ').map { it.toInt() } }
	for (i in 0 until N) {
		var cnt = 0
		for (j in 0 until M) if (A[i][j] == K) cnt += 1
		println(cnt)
	}
}
```
- - -
##### PHP
###### 3の倍数のカウント
```php
<?php
	$N = intval(fgets(STDIN));
	$A = array_map("intval", explode(' ', fgets(STDIN)));
	$cnt = 0;
	for ($i = 0; $i < $N; $i++) if ($A[$i] % 3 === 0) $cnt++;
	echo $cnt, PHP_EOL;
?>
```
###### フラグ管理
```php
<?php
	$N = intval(fgets(STDIN));
	$A = [];
	for ($i = 0; $i < $N; $i++) $A[] = intval(fgets(STDIN));
	$flg = 0;
	for ($i = 0; $i < $N; $i++) {
		if ($A[$i] === 7) {
			$flg = 1;
			break;
		}
	}
	echo $flg ? "YES" : "NO", PHP_EOL;
?>
```
###### インデックス取得
```php
<?php
	$N = intval(fgets(STDIN));
	$A = [];
	for ($i = 0; $i < $N; $i++) $A[] = intval(fgets(STDIN));
	$k = intval(fgets(STDIN));
	for ($i = 0; $i < $N; $i++) {
		if ($A[$i] === $k) {
			echo $i + 1, PHP_EOL;
			break;
		}
	} 
?>
```
###### 多重ループ
```php
<?php
	$M = intval(fgets(STDIN));
	$C = [];
	for ($i = 0; $i < $M; $i++) $C[] = fgets(STDIN)[0];
	$N = intval(fgets(STDIN));
	$S = [];
	for ($j = 0; $j < $N; $j++) $S[] = trim(fgets(STDIN));
	for ($i = 0; $i < $M; $i++) {
		for ($j = 0; $j < $N; $j++) {
			echo strpos($S[$j], $C[$i]) === false ? "NO" : "YES", PHP_EOL;
		}
	}
?>
```
###### forループ
```php
<?php
	[$N, $M, $K] = array_map("intval", explode(' ', fgets(STDIN)));
	$A = [];
	for ($i = 0; $i < $N; $i++) $A[] = array_map("intval", explode(' ', fgets(STDIN)));
	for ($i = 0; $i < $N; $i++) {
		$cnt = 0;
		for ($j = 0; $j < $M; $j++) $cnt += $A[$i][$j] === $K;
		echo $cnt, PHP_EOL;
	}
?>
```
- - -
##### Perl
###### 3の倍数のカウント
```pl
my $N = int(<STDIN>);
my @A = map { int($_) } split ' ', <STDIN>;
my $cnt = 0;
for (my $i = 0; $i < $N; $i++) {
	if ($A[$i] % 3 == 0) {
		$cnt++;
	}
}
print "$cnt$/";
```
###### フラグ管理
```pl
my $N = int(<STDIN>);
my @A;
for (1..$N) {
	push @A, int(<STDIN>);
}
my $flg = 0;
for (my $i = 0; $i < $N; $i++) {
	if ($A[$i] == 7) {
		$flg = 1;
		last;
	}
}
print $flg ? "YES" : "NO", $/;
```
###### インデックス取得
```pl
my $N = int(<STDIN>);
my @A;
for (1..$N) {
	push @A, int(<STDIN>);
}
my $k = int(<STDIN>);
for (my $i = 0; $i < $N; $i++) {
	if ($A[$i] == $k) {
		print $i + 1, $/;
		last;
	}
}
```
###### 多重ループ
```pl
my $M = int(<STDIN>);
my @C;
for (1..$M) {
	chomp(my $c = <STDIN>);
	push @C, $c;
}
my $N = int(<STDIN>);
my @S;
for (1..$N) {
	chomp(my $s = <STDIN>);
	push @S, $s;
}
for (my $i = 0; $i < $M; $i++) {
	for (my $j = 0; $j < $N; $j++) {
		print index($S[$j], $C[$i]) == -1 ? "NO" : "YES", $/;
	}
}
```
###### forループ
```pl
my ($N, $M, $K) = map { int($_) } split ' ', <STDIN>;
my @A;
for (1..$N) {
	push @A, [split ' ', <STDIN>];
}
for (my $i = 0; $i < $N; $i++) {
	my $cnt = 0;
	for (my $j = 0; $j < $M; $j++) {
		if ($A[$i][$j] == $K) {
			$cnt++;
		}
	}
	print "$cnt$/";
}
```
- - -
##### Python3
###### 3の倍数のカウント
```py
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
	if A[i] % 3 == 0:
		cnt += 1
print(cnt)
```
###### フラグ管理
```py
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
	if A[i] == 7:
		print("YES")
		break
else:
	print("NO")
```
###### インデックス取得
```py
N = int(input())
A = [int(input()) for _ in range(N)]
K = int(input())
for i in range(N):
	if A[i] == K:
		print(i + 1)
		break
```
###### 多重ループ
```py
M = int(input())
C = [input()[0] for _ in range(M)]
N = int(input())
S = [input() for _ in range(N)]
for i in range(M):
	for j in range(N):
		print("YES" if C[i] in S[j] else "NO")
```
###### forループ
```py
N, M, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
	cnt = 0
	for j in range(M):
		cnt += A[i][j] == K
	print(cnt)
```
- - -
##### Ruby
###### 3の倍数のカウント
```rb
N = gets.to_i
A = gets.split.map(&:to_i)
cnt = 0
N.times do |i|
	if A[i] % 3 == 0
		cnt += 1
	end
end
p cnt
```
###### フラグ管理
```rb
puts gets.to_i.times.map { gets.to_i }.any? { |x| x == 7 } ? "YES" : "NO"
```
###### インデックス取得
```rb
N = gets.to_i
A = N.times.map { gets.to_i }
K = gets.to_i
N.times do |i|
	if A[i] == K
		p i + 1
		break
	end
end
```
###### 多重ループ
```rb
M = gets.to_i
C = M.times.map { gets[0] }
N = gets.to_i
S = N.times.map { gets.chomp }
M.times do |i|
	N.times do |j|
		print S[j].index(C[i]) ? "YES" : "NO"
		puts
	end
end
```
###### forループ
```rb
N, M, K = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }
N.times do |i|
	cnt = 0
	M.times do |j|
		if A[i][j] == K
			cnt += 1
		end
	end
	p cnt
end
```
- - -
##### Scala
###### 3の倍数のカウント
```scala
import scala.io.StdIn._

object Main extends App{
	val N = readInt()
	val A = readLine().split(' ').map { _.toInt }
	var cnt = 0
	for (i <- 0 until N) if (A(i) % 3 == 0) cnt += 1
	println(cnt)
}
```
###### フラグ管理
```scala
import scala.io.StdIn._

object Main extends App{
	val N = readInt()
	val A = Array.fill(N) { readInt() }
	var flg = false
	for (i <- 0 until N) if (A(i) == 7) flg = true
	println(if (flg) "YES" else "NO")
}
```
###### インデックス取得
```scala
import scala.io.StdIn._

object Main extends App{
	val N = readInt()
	val A = Array.fill(N) { readInt() }
	val k = readInt()
	var idx = -1
	for (i <- 0 until N) {
		if (idx == -1 && A(i) == k) {
			println(i + 1)
			idx = i
		}
	}
}
```
###### 多重ループ
```scala
import scala.io.StdIn._

object Main extends App{
	val M = readInt()
	val C = Array.fill(M) { readLine()(0) }
	val N = readInt()
	val S = Array.fill(N) { readLine() }
	for (i <- 0 until M) {
		for (j <- 0 until N) {
			println(if (S(j).indexOf(C(i)) == -1) "NO" else "YES")
		}
	}
}
```
###### forループ
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(n, m, k) = readLine().split(' ').map { _.toInt }
	val A = Array.fill(n) { readLine().split(' ').map { _.toInt } }
	for (i <- 0 until n) {
		var cnt = 0
		for (j <- 0 until m) if (A(i)(j) == k) cnt += 1
		println(cnt)
	}
}
```
- - -
##### Swift
###### 3の倍数のカウント
```swift
let N = Int(readLine()!)!
let A = readLine()!.split(separator: " ").compactMap { Int($0) }
var cnt = 0
for i in 0..<N {
	if A[i] % 3 == 0 {
		cnt += 1
	}
}
print(cnt)
```
###### フラグ管理
```swift
let N = Int(readLine()!)!
var A: [Int] = []
for _ in 0..<N {
	A.append(Int(readLine()!)!)
}
var flg = false
for i in 0..<N {
	if A[i] == 7 {
		flg = true
		break
	}
}
print(flg ? "YES" : "NO")
```
###### インデックス取得
```swift
let N = Int(readLine()!)!
var A: [Int] = []
for _ in 0..<N {
	A.append(Int(readLine()!)!)
}
let K = Int(readLine()!)!
for i in 0..<N {
	if A[i] == K {
		print(i + 1)
		break
	}
}
```
###### 多重ループ
```swift
import Foundation

let M = Int(readLine()!)!
var C: [String] = []
for _ in 0..<M {
	C.append(readLine()!)
}
let N = Int(readLine()!)!
var S: [String] = []
for _ in 0..<N {
	S.append(readLine()!)
}
for i in 0..<M {
	for j in 0..<N {
		print(S[j].contains(C[i]) ? "YES" : "NO")
	}
}
```
###### forループ
```swift
let nmk = readLine()!.split(separator: " ").compactMap { Int($0) }
let (N, M, K) = (nmk[0], nmk[1], nmk[2])
var A: [[Int]] = []
for _ in 0..<N {
	A.append(readLine()!.split(separator: " ").compactMap { Int($0) })
}
for i in 0..<N {
	var cnt = 0
	for j in 0..<M {
		if A[i][j] == K {
			cnt += 1
		}
	}
	print(cnt)
}
```