[CodeUp]C言語基礎100題(1081~1090)-Java
38382 ワード
✔ 1081 8 (2^3) bit = 1Byte 1024 (2^10) Byte = 1KB 1024 (2^10) KB = 1MB 合計
✔ 1086
✔ 1087
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
System.out.println(i + " " + j);
}
}
}
}
✔ 1082import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String n = sc.nextLine();
int decimal = Integer.parseInt(n, 16);
for (int i = 1; i < 16; i++) {
System.out.println(n + "*" + Integer.toHexString(i).toUpperCase() + "=" + Integer.toHexString(decimal * i).toUpperCase());
}
}
}
✔ 1083import java.util.Scanner;
public class Main{
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
if (i == 3 || i == 6 || i == 9) {
System.out.print("X ");
} else {
System.out.print(i+" ");
}
}
}
}
✔ 1084import java.util.Scanner;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
int r = sc.nextInt();
int g = sc.nextInt();
int b = sc.nextInt();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int count = 0;
for (int i = 0; i < r; i++) {
for (int j = 0; j < g; j++) {
for (int k = 0; k < b; k++) {
bw.write(i + " " + j + " " + k + "\n");
count++;
}
}
}
bw.write(String.valueOf(count));
bw.flush();
}
}
✔ 1085import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long h = sc.nextLong(); // Hz
long b = sc.nextLong(); // 비트 수
long c = sc.nextLong(); // 채널 - 모노, 스테레오
long s = sc.nextLong(); // 녹음 시간
double total = h * b * c * s;
total /= Math.pow(2, 23);
System.out.println(String.format("%.1f MB", total));
}
}
小数点の2番目に四捨五入したMB単位で出力します.2^23
に分割された後、String.format
を使用して1つの位置に出力される.✔ 1086
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int w = sc.nextInt(); // 가로 해상도, 정수, 1_1024
int h = sc.nextInt(); // 세로 해상도, 정수, 1_1024
int b = sc.nextInt(); // 한 픽셀을 저장하기 위한 비트, 40 이하의 4의 배수
double total = w * h * b;
total /= Math.pow(2, 23);
System.out.println(String.format("%.2f MB", total));
}
}
横、縦、桁数にMBを乗じた単位で小数点に出力される2桁.✔ 1087
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0, i = 1;
while (sum < n) {
sum += i++;
}
System.out.println(sum);
}
}
✔ 1088import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
if (i % 3 == 0) continue;
System.out.print(i+" ");
}
}
}
✔ 1089import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int d = sc.nextInt();
int n = sc.nextInt();
if (n == 1) {
System.out.println(a);
return;
}
int result = a;
for (int i = 2; i <= n; i++) {
result += d;
}
System.out.print(result);
}
}
✔ 1090import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int r = sc.nextInt();
int n = sc.nextInt();
if (n == 1) {
System.out.println(a);
return;
}
long result = a;
for (int i = 2; i <= n; i++) {
result *= r;
}
System.out.print(result);
}
}
数量が大きくなると、戻る制限範囲を超えてしまう可能性があるので、資料型をlongに選択しました.Reference
この問題について([CodeUp]C言語基礎100題(1081~1090)-Java), 我々は、より多くの情報をここで見つけました https://velog.io/@ffwang/코드업-C언어-기초-100제-10811090-Javaテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol