0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Posted at

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


問題
足し算

引き算・掛け算

割り算

掛け算2

累乗

累乗2


C
足し算
#include <stdio.h>

int main() {
	printf("%d\n", 1231 + 5178);
}
引き算・掛け算
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int d = a - b;
	int p = a * b;
	printf("%d %d\n", d, p);
	return 0;
}
割り算
#include <stdio.h>

const int A = 437326;
const int B = 9085;

int main() {
	printf("%d %d\n", A / B, A % B);
	return 0;
}
掛け算2
#include <stdio.h>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int x = a * a;
	int y = b * b + c * c;
	printf("%d %d\n", x, y);
	return 0;
}
累乗
#include <stdio.h>

const int A = 202;
const int B = 134;
const int C = 107;

int main() {
	int n = (A + B) * C;
	printf("%d\n", n * n);
	return 0;
}
累乗2
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int n = (a + b) * c;
	printf("%d\n", n * n % d);
	return 0;
}

C++
足し算
#include <iostream>
using namespace std;

int main() {
	cout << 1231 + 5178 << endl;
	return 0;
}
引き算・掛け算
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int d = a - b;
	int p = a * b;
	cout << d << ' ' << p << endl;
	return 0;
}
割り算
#include <iostream>
using namespace std;

const int A = 437326;
const int B = 9085;

int main() {
	cout << A / B << ' ' << A % B << endl;
	return 0;
}
掛け算2
#include <iostream>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int x = a * a;
	int y = b * b + c * c;
	cout << x << ' ' << y << endl;
	return 0;
}
累乗
#include <iostream>
using namespace std;

const int A = 202;
const int B = 134;
const int C = 107;

int main() {
	int n = (A + B) * C;
	cout << n * n << endl;
	return 0;
}
累乗2
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int n = (a + b) * c;
	cout << n * n % d << endl;
	return 0;
}

C#
足し算
using System;

class Program
{
	public static void Main()
	{
		Console.WriteLine(1231 + 5178);
	}
}
引き算・掛け算
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];
		int d = a - b;
		int p = a * b;
		Console.WriteLine("" + d + ' ' + p);
	}
}
割り算
using System;

class Program
{
	private const int A = 437326;
	private const int B = 9085;

	public static void Main()
	{
		Console.Write(A / B);
		Console.Write(' ');
		Console.Write(A % B);
		Console.WriteLine();
	}
}
掛け算2
using System;

class Program
{
	public static void Main()
	{
		int[] abc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a = abc[0];
		int b = abc[1];
		int c = abc[2];
		int x = a * a;
		int y = b * b + c * c;
		Console.WriteLine("" + x + ' ' + y);
	}
}
累乗
using System;

class Program
{
	private const int A = 202;
	private const int B = 134;
	private const int C = 107;
	
	public static void Main()
	{
		int n = (A + B) * C;
		Console.WriteLine(n * n);
	}
}
累乗2
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];
		int n = (a + b) * c;
		Console.WriteLine(n * n % d);
	}
}
- - -
##### Go
###### 足し算
```go
package main
import "fmt"

func main() {
	fmt.Println(1231 + 5178)
}
引き算・掛け算
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	d := a - b
	p := a * b
	fmt.Println(d, p)
}
割り算
package main
import "fmt"

const A = 437326
const B = 9085

func main() {
	fmt.Println(A / B, A % B)
}
掛け算2
package main
import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	x := a * a
	y := b * b + c * c
	fmt.Println(x, y)
}
累乗
package main
import "fmt"

const A = 202;
const B = 134;
const C = 107;

func main() {
	n := (A + B) * C
	fmt.Println(n * n)
}
累乗2
package main
import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	n := (a + b) * c
	fmt.Println(n * n % d)
}

Java
足し算
public class Main {
	public static void main(String[] args) {
		System.out.println(1231 + 5178);
	}
}
引き算・掛け算
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();
		sc.close();
		int d = a - b;
		int p = a * b;
		System.out.println("" + d + ' ' + p);
	}
}
割り算
public class Main {
	
	private static final int A = 437326;
	private static final int B = 9085;
	
	public static void main(String[] args) {
		System.out.print(A / B);
		System.out.print(' ');
		System.out.print(A % B);
		System.out.println();
	}
}
掛け算2
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();
		sc.close();
		int x = a * a;
		int y = b * b + c * c;
		System.out.println("" + x + ' ' + y);
	}
}
累乗
public class Main {
	
	private static final int A = 202;
	private static final int B = 134;
	private static final int C = 107;

	public static void main(String[] args) {
		int n = (A + B) * C;
		System.out.println(n * n);
	}
}
累乗2
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();
		sc.close();
		int n = (a + b) * c;
		System.out.println(n * n % d);
	}
}

JavaScript
足し算
console.log(1231 + 5178);
引き算・掛け算
const [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
const d = a - b
const p = a * b
console.log(d, p);
割り算
const A = 437326;
const B = 9085;
console.log(parseInt(A / B), A % B);
掛け算2
const [a, b, c] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
const x = a * a;
const y = b * b + c * c
console.log(x, y);
累乗
const A = 202;
const B = 134;
const C = 107;
console.log(((A + B) * C) ** 2);
累乗2
const [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(' ').map(Number);
console.log(((a + b) * c) ** 2 % d);

Kotlin
足し算
fun main() {
	println(1231 + 5178)
}
引き算・掛け算
fun main() {
	val (a, b) = readLine()!!.split(' ').map { it.toInt() }
	val d = a - b
	val p = a * b
	println("" + d + " " + p)
}
割り算
val A = 437326;
val B = 9085;

fun main() {
	print(A / B)
	print(' ')
	print(A % B)
	println()
}
掛け算2
fun main() {
	val (a, b, c) = readLine()!!.split(' ').map { it.toInt() }
	val x = a * a
	val y = b * b + c * c
	println("" + x + ' ' + y)
}
累乗
val A = 202;
val B = 134;
val C = 107;

fun main() {
	val n = (A + B) * C
	println(n * n)
}
累乗2
fun main() {
	val (a, b, c, d) = readLine()!!.split(' ').map { it.toInt() }
	val n = (a + b) * c
	println(n * n % d)
}

PHP
足し算
<?php
	echo 1231 + 5178, PHP_EOL;
?>
引き算・掛け算
<?php
	[$a, $b] = array_map("intval", explode(' ', fgets(STDIN)));
	$d = $a - $b;
	$p = $a * $b;
	echo "$d $p", PHP_EOL;
?>
割り算
<?php
	const A = 437326;
	const B = 9085;
	echo intdiv(A, B), ' ', A % B, PHP_EOL;
?>
掛け算2
<?php
	[$a, $b, $c] = array_map('intval', explode(' ', fgets(STDIN)));
	$x = $a * $a;
	$y = $b * $b + $c * $c;
	echo "$x $y", PHP_EOL;
?>
累乗
<?php
	const A = 202;
	const B = 134;
	const C = 107;
	echo ((A + B) * C) ** 2, PHP_EOL;
?>
累乗2
<?php
	[$a, $b, $c, $d] = array_map('intval', explode(' ', fgets(STDIN)));
	echo (($a + $b) * $c) ** 2 % $d, PHP_EOL;
?>

Perl
足し算
print 1231 + 5178, $/;
引き算・掛け算
my ($a, $b) = map { int($_) } split ' ', <STDIN>;
my $d = $a - $b;
my $p = $a * $b;
print "$d $p$/";
割り算
my $A = 437326;
my $B = 9085;
print int($A / $B), ' ', $A % $B, $/;
掛け算2
my ($a, $b, $c) = map { int($_) } split ' ', <STDIN>;
my $x = $a * $a;
my $y = $b * $b + $c * $c;
print "$x $y$/";
累乗
my $A = 202;
my $B = 134;
my $C = 107;
my $n = ($A + $B) * $C;
print $n ** 2, $/;
累乗2
my ($a, $b, $c, $d) = map { int($_) } split ' ', <STDIN>;
my $n = ($a + $b) * $c;
print $n ** 2 % $d, $/;

Python3
足し算
print(1231 + 5178)
引き算・掛け算
a, b = map(int, input().split())
d = a - b
p = a * b
print(d, p)
割り算
A = 437326
B = 9085
print(A // B, A % B)
掛け算2
a, b, c = map(int, input().split())
x = a * a
y = b * b + c * c
print(x, y)
累乗
A = 202
B = 134
C = 107
print(((A + B) * C) ** 2)
累乗2
a, b, c, d = map(int, input().split())
print(((a + b) * c) ** 2 % d)

Ruby
足し算
p 1231 + 5178
引き算・掛け算
a, b = gets.split.map(&:to_i)
d = a - b
p = a * b
print d, ' ', p, "\n"
割り算
A = 437326
B = 9085
print A / B, ' ', A % B, "\n"
掛け算2
a, b, c = gets.split.map(&:to_i)
x = a * a
y = b * b + c * c
print x, ' ', y, "\n"
累乗
A = 202
B = 134
C = 107
p ((A + B) * C) ** 2
累乗2
a, b, c, d = gets.split.map(&:to_i)
p ((a + b) * c) ** 2 % d

Scala
足し算
object Main extends App{
	println(1231 + 5178)
}
引き算・掛け算
import scala.io.StdIn._

object Main extends App{
	val Array(a, b) = readLine().split(' ').map { _.toInt }
	val d = a - b
	val p = a * b
	println("" + d + ' ' + p)
}
割り算
object Main extends App{
	val A = 437326
	val B = 9085
	print(A / B)
	print(' ')
	print(A % B)
	println()
}
掛け算2
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c) = readLine().split(' ').map { _.toInt }
	val x = a * a
	val y = b * b + c * c
	println("" + x + ' ' + y)
}
累乗
object Main extends App{
	val A = 202
	val B = 134
	val C = 107
	val n = (A + B) * C
	println(n * n)
}
累乗2
import scala.io.StdIn._

object Main extends App{
	val Array(a, b, c, d) = readLine().split(' ').map { _.toInt }
	val n = (a + b) * c
	println(n * n % d)
}

Swift
足し算
print(1231 + 5178)
引き算・掛け算
let ab = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b) = (ab[0], ab[1])
let d = a - b
let p = a * b
print(d, p)
割り算
let A = 437326
let B = 9085
print(A / B, A % B)
掛け算2
let abc = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c) = (abc[0], abc[1], abc[2])
let x = a * a
let y = b * b + c * c
print(x, y)
累乗
let A = 202
let B = 134
let C = 107
let n = (A + B) * C
print(n * n)
累乗2
let abcd = readLine()!.split(separator: " ").compactMap { Int($0) }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])
let n = (a + b) * c
print(n * n % d)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?