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

paizaラーニングレベルアップ問題集の【論理演算子】をやってみました。
- - -
##### 問題
###### STEP: 1 AND演算子
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_step1
###### STEP: 2 OR演算子
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_step2
###### STEP: 3 NOT演算子
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_step3
###### STEP: 4 NOT演算子2
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_step4
###### STEP: 5 論理演算子の組み合わせ
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_step5
###### STEP: 6 論理演算子の組み合わせ2
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_step6
###### FINAL問題 論理演算子の組み合わせ3
https://paiza.jp/works/mondai/conditions_expression/conditions_expression__logical_operator_boss
- - -
##### C
###### STEP: 1 AND演算子
```c
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", a == b && c == d);
	return 0;
}
```
###### STEP: 2 OR演算子
```c
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", a == b || c == d);
	return 0;
}
```
###### STEP: 3 NOT演算子
```c
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", !(a == b));
	return 0;
}
```
###### STEP: 4 NOT演算子2
```c
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", !(a == b && c == d));
	return 0;
}
```
###### STEP: 5 論理演算子の組み合わせ
```c
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", a == b && b == c && c == d);
	return 0;
}
```
###### STEP: 6 論理演算子の組み合わせ2
```c
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", a == b && c == d || a == c && b == d);
	return 0;
}
```
###### FINAL問題 論理演算子の組み合わせ3
```c
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", (a == b || c == d) && a == c);
	return 0;
}
```
- - -
##### C++
###### STEP: 1 AND演算子
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a == b && c == d) << endl;
	return 0;
}
```
###### STEP: 2 OR演算子
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a == b || c == d) << endl;
	return 0;
}
```
###### STEP: 3 NOT演算子
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << !(a == b) << endl;
	return 0;
}
```
###### STEP: 4 NOT演算子2
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << !(a == b && c == d) << endl;
	return 0;
}
```
###### STEP: 5 論理演算子の組み合わせ
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a == b && b == c && c == d) << endl;
	return 0;
}
```
###### STEP: 6 論理演算子の組み合わせ2
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a == b && c == d || a == c && b == d) << endl;
	return 0;
}
```
###### FINAL問題 論理演算子の組み合わせ3
```cpp
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((a == b || c == d) && a == c) << endl;
	return 0;
}
```
- - -
##### C#
###### STEP: 1 AND演算子
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abcd[0];
		int b = abcd[1];
		int c = abcd[2];
		int d = abcd[3];
		Console.WriteLine(a == b && c == d);
	}
}
```
###### STEP: 2 OR演算子
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abcd[0];
		int b = abcd[1];
		int c = abcd[2];
		int d = abcd[3];
		Console.WriteLine(a == b || c == d);
	}
}
```
###### STEP: 3 NOT演算子
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = ab[0];
		int b = ab[1];
		Console.WriteLine(!(a == b));
	}
}
```
###### STEP: 4 NOT演算子2
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abcd[0];
		int b = abcd[1];
		int c = abcd[2];
		int d = abcd[3];
		Console.WriteLine(!(a == b && c == d));
	}
}
```
###### STEP: 5 論理演算子の組み合わせ
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abcd[0];
		int b = abcd[1];
		int c = abcd[2];
		int d = abcd[3];
		Console.WriteLine(a == b && b == c && c == d);
	}
}
```
###### STEP: 6 論理演算子の組み合わせ2
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abcd[0];
		int b = abcd[1];
		int c = abcd[2];
		int d = abcd[3];
		Console.WriteLine(a == b && c == d || a == c && b == d);
	}
}
```
###### FINAL問題 論理演算子の組み合わせ3
```cs
using System;

class Program
{
	public static void Main()
	{
		int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abcd[0];
		int b = abcd[1];
		int c = abcd[2];
		int d = abcd[3];
		Console.WriteLine((a == b || c == d) && a == c);
	}
}
```
- - -
##### Go
###### STEP: 1 AND演算子
```go
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(a == b && c == d)
}
```
###### STEP: 2 OR演算子
```go
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(a == b || c == d)
}
```
###### STEP: 3 NOT演算子
```go
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(!(a == b))
}
```
###### STEP: 4 NOT演算子2
```go
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(!(a == b && c == d))
}
```
###### STEP: 5 論理演算子の組み合わせ
```go
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(a == b && b == c && c == d)
}
```
###### STEP: 6 論理演算子の組み合わせ2
```go
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(a == b && c == d || a == c && b == d)
}
```
###### FINAL問題 論理演算子の組み合わせ3
```go
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println((a == b || c == d) && a == c)
}
```
- - -
##### Java
###### STEP: 1 AND演算子
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(sc.nextInt() == sc.nextInt() && sc.nextInt() == sc.nextInt());
		sc.close();
	}
}
```
###### STEP: 2 OR演算子
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(sc.nextInt() == sc.nextInt() || sc.nextInt() == sc.nextInt());
		sc.close();
	}
}
```
###### STEP: 3 NOT演算子
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(!(sc.nextInt() == sc.nextInt()));
		sc.close();
	}
}
```
###### STEP: 4 NOT演算子2
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(!(sc.nextInt() == sc.nextInt() && sc.nextInt() == sc.nextInt()));
		sc.close();
	}
}
```
###### STEP: 5 論理演算子の組み合わせ
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(a == b && b == c && c == d);
		sc.close();
	}
}
```
###### STEP: 6 論理演算子の組み合わせ2
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(a == b && c == d || a == c && b == d);
		sc.close();
	}
}
```
###### FINAL問題 論理演算子の組み合わせ3
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println((a == b || c == d) && a == c);
		sc.close();
	}
}
```
- - -
##### JavaScript
###### STEP: 1 AND演算子
```js
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a === b && c === d);
```
###### STEP: 2 OR演算子
```js
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a === b || c === d);
```
###### STEP: 3 NOT演算子
```js
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(!(a === b));
```
###### STEP: 4 NOT演算子2
```js
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(!(a === b && c === d));
```
###### STEP: 5 論理演算子の組み合わせ
```js
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a === b && b === c && c === d);
```
###### STEP: 6 論理演算子の組み合わせ2
```js
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(a === b && c === d || a === c && b === d);
```
###### FINAL問題 論理演算子の組み合わせ3
```js
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log((a === b || c === d) && a === c);
```
- - -
##### Kotlin
###### STEP: 1 AND演算子
```kotlin
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	println(a == b && c == d)
}
```
###### STEP: 2 OR演算子
```kotlin
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	println(a == b || c == d)
}
```
###### STEP: 3 NOT演算子
```kotlin
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	println(!(a == b))
}
```
###### STEP: 4 NOT演算子2
```kotlin
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	println(!(a == b && c == d))
}
```
###### STEP: 5 論理演算子の組み合わせ
```kotlin
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	println(a == b && b == c && c == d)
}
```
###### STEP: 6 論理演算子の組み合わせ2
```kotlin
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	println(a == b && c == d || a == c && b == d)
}
```
###### FINAL問題 論理演算子の組み合わせ3
```kotlin
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	println((a == b || c == d) && a == c)
}
```
- - -
##### PHP
###### STEP: 1 AND演算子
```php
<?php
	[$a, $b, $c, $d] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a === $b && $c === $d ? 1 : 0, PHP_EOL;
?>
```
###### STEP: 2 OR演算子
```php
<?php
	[$a, $b, $c, $d] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a === $b || $c === $d ? 1 : 0, PHP_EOL;
?>
```
###### STEP: 3 NOT演算子
```php
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	echo !($a === $b) ? 1 : 0, PHP_EOL;
?>
```
###### STEP: 4 NOT演算子2
```php
<?php
	[$a, $b, $c, $d] = array_map("intval", explode(' ', fgets(STDIN)));
	echo !($a === $b && $c === $d) ? 1 : 0, PHP_EOL;
?>
```
###### STEP: 5 論理演算子の組み合わせ
```php
<?php
	[$a, $b, $c, $d] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a === $b && $b === $c && $c === $d ? 1 : 0, PHP_EOL;
?>
```
###### STEP: 6 論理演算子の組み合わせ2
```php
<?php
	[$a, $b, $c, $d] = array_map("intval", explode(' ', fgets(STDIN)));
	echo $a === $b && $c === $d || $a === $c && $b === $d ? 1 : 0, PHP_EOL;
?>
```
###### FINAL問題 論理演算子の組み合わせ3
```php
<?php
	[$a, $b, $c, $d] = array_map("intval", explode(' ', fgets(STDIN)));
	echo ($a === $b || $c === $d) && $a === $c ? 1 : 0, PHP_EOL;
?>
```
- - -
##### Perl
###### STEP: 1 AND演算子
```pl
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
print $a == $b && $c == $d ? 1 : 0, $/;
```
###### STEP: 2 OR演算子
```pl
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
print $a == $b || $c == $d ? 1 : 0, $/;
```
###### STEP: 3 NOT演算子
```pl
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
print !($a == $b) ? 1 : 0, $/;
```
###### STEP: 4 NOT演算子2
```pl
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
print !($a == $b && $c == $d) ? 1 : 0, $/;
```
###### STEP: 5 論理演算子の組み合わせ
```pl
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
print $a == $b && $b == $c && $c == $d ? 1 : 0, $/;
```
###### STEP: 6 論理演算子の組み合わせ2
```pl
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
print $a == $b && $c == $d || $a == $c && $b == $d ? 1 : 0, $/;
```
###### FINAL問題 論理演算子の組み合わせ3
```pl
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
print ($a == $b || $c == $d) && $a == $c ? 1 : 0, $/;
```
- - -
##### Python3
###### STEP: 1 AND演算子
```py
a, b, c, d = map(int, input().split())
print(a == b and c == d)
```
###### STEP: 2 OR演算子
```py
a, b, c, d = map(int, input().split())
print(a == b or c == d)
```
###### STEP: 3 NOT演算子
```py
a, b = map(int, input().split())
print(not a == b)
```
###### STEP: 4 NOT演算子2
```py
a, b, c, d = map(int, input().split())
print(not (a == b and c == d))
```
###### STEP: 5 論理演算子の組み合わせ
```py
a, b, c, d = map(int, input().split())
print(a == b and b == c and c == d)
```
###### STEP: 5 論理演算子の組み合わせ
```py
a, b, c, d = map(int, input().split())
print(a == b and c == d or a == c and b == d)
```
###### FINAL問題 論理演算子の組み合わせ3
```py
a, b, c, d = map(int, input().split())
print((a == b or c == d) and a == c)
```
- - -
##### Ruby
###### STEP: 1 AND演算子
```rb
a, b, c, d = gets.split.map(&:to_i)
p a == b && c == d
```
###### STEP: 2 OR演算子
```rb
a, b, c, d = gets.split.map(&:to_i)
p a == b || c == d
```
###### STEP: 3 NOT演算子
```rb
a, b = gets.split.map(&:to_i)
p !(a == b)
```
###### STEP: 4 NOT演算子2
```rb
a, b, c, d = gets.split.map(&:to_i)
p !(a == b && c == d)
```
###### STEP: 5 論理演算子の組み合わせ
```rb
a, b, c, d = gets.split.map(&:to_i)
p a == b && b == c && c == d
```
###### STEP: 6 論理演算子の組み合わせ2
```rb
a, b, c, d = gets.split.map(&:to_i)
p a == b && c == d || a == c && b == d
```
###### FINAL問題 論理演算子の組み合わせ3
```rb
a, b, c, d = gets.split.map(&:to_i)
p (a == b || c == d) && a == c
```
- - -
##### Scala
###### STEP: 1 AND演算子
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	println(a == b && c == d)
}
```
###### STEP: 2 OR演算子
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	println(a == b || c == d)
}
```
###### STEP: 3 NOT演算子
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	println(!(a == b))
}
```
###### STEP: 4 NOT演算子2
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	println(!(a == b && c == d))
}
```
###### STEP: 5 論理演算子の組み合わせ
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	println(a == b && b == c && c == d)
}
```
###### STEP: 6 論理演算子の組み合わせ2
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	println(a == b && c == d || a == c && b == d)
}
```
###### FINAL問題 論理演算子の組み合わせ3
```scala
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	println((a == b || c == d) && a == c)
}
```
- - -
##### Swift
###### STEP: 1 AND演算子
```swift
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
print(a == b && c == d)
```
###### STEP: 2 OR演算子
```swift
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
print(a == b || c == d)
```
###### STEP: 3 NOT演算子
```swift
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
print(!(a == b))
```
###### STEP: 4 NOT演算子2
```swift
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
print(!(a == b && c == d))
```
###### STEP: 5 論理演算子の組み合わせ
```swift
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
print(a == b && b == c && c == d)
```
###### STEP: 6 論理演算子の組み合わせ2
```swift
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
print(a == b && c == d || a == c && b == d)
```
###### FINAL問題 論理演算子の組み合わせ3
```swift
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
print((a == b || c == d) && a == c)
```