728x90
반응형
78 : 짝수 합 구하기
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
sc.close();
int b = 0;
for(int i=0;i<b;i++){
if(i%2==0){
b += i;
}
}
System.out.println(a);
}
}
79 : 원하는 문자가 입력될 때까지 반복 출력하기
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
char ch;
while(true){
ch = sc.next().charAt(0);
if(ch == 'q'){
break;
}
System.out.println(a);
}
sc.close();
}
}
80 : 언제까지 더해야 할까?
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = 0, i = 0;
while(b<a){
i++;
b += i;
}
System.out.println(i);
sc.close();
}
}
81 : 주사위를 2개 던지면?
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n>0 && n<=10){
int m = sc.nextInt();
sc.close();
if(m>0 && m<=10){
for(int i =1;i<=n;i++){
for(int j =1;j<=m;j++){
System.out.print(i+" "+j);
System.out.println();
}
}
} else{
}
} else{
}
}
}
82 : 16진수 구구단?
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(16
sc.close();
for(int i=1;i<16++){
System.out.println("%X*%X=%X\n", a,i,a*i);
}
}
}
83 : 3 6 9 게임의 왕이 되자!
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
sc.close();
for(int i=1;i<=a;i++){
if(i%3==0){
System.out.print("X ");
}
} else {
System.out.println(i + " ");
}
}
}
}
84 : 빛 섞어 색 만들기
//자바코드
import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
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();
BufferedWriter bf = new BufferedWriter(new OutputStreamWriter(System.out));
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
for(int k=0;k<c;k++){
String st = i+ " " + j +" " +k;
bf.write(st + "\n");
}
}
}
bf.write(Integer.toString(a*b*c);
bf.close();
}
}
85 : 소리 파일 저장용량 계산하기
//자바코드
import java.util.Scanner;
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();
double cal = Math.pow(2, 23);
double total = a*b*c*d;
double result = total/cal;
System.out.println("%.1f MB", result));
}
}
86 : 그림 파일 저장용량 계산하기
//자바코드
import java.util.Scanner;
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();
double cal = Math.pow(2, 23);
double total = a*b*c;
double result = total/cal;
System.out.println("%.2f MB", result));
}
}
728x90
반응형
'Coding Test > CodeUp' 카테고리의 다른 글
CodeUp_Java 기초 100제 - [기초-1차원배열] 93~95 (0) | 2022.02.14 |
---|---|
CodeUp_Java 기초 100제 - [기초-종합] 87~92 (0) | 2022.02.14 |
CodeUp_Java 기초 100제 - [기초-반복실행구조] 74~77 (0) | 2022.02.14 |
CodeUp_Java 기초 100제 - [기초-반복실행구조] 0 입력될 때까지 무한 출력하기(1)~(3) 71~73 (0) | 2022.02.14 |
CodeUp_Java 기초 100제 - [기초-조건/선택실행구조] 월 입력받아 계절 출력하기 70 (0) | 2022.02.13 |
댓글