728x90
반응형
SMALL
형성평가1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
for (int i = 0; i < a; i++) System.out.println("JUNGOL");
}
}
형성평가2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
int min = a < b ? a : b;
int max = a > b ? a : b;
for(int i = min; i <= max; i++) System.out.print(i + " ");
}
}
형성평가3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), sum = 0;
for(int i = 1; i <= a; i++)if(i%5 == 0) sum += i;
System.out.println(sum);
}
}
형성평가4
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int sum = 0;
for(int i = 0; i < a; i++) sum += sc.nextInt();
double avg = (double)sum/a;
System.out.printf("%.2f", avg);
}
}
형성평가5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a,even = 0, odd = 0;
for(int i = 0; i < 10; i++){
a = sc.nextInt();
if(a%2 == 0) even++;
else odd++;
}
System.out.println("even : " + even);
System.out.println("odd : " + odd);
}
}
형성평가6
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt(), count = 0;
double sum = 0.0;
int min = a < b ? a : b;
int max = a > b ? a : b;
for(int i = min; i<= max; i++){
if(i%3 == 0 || i%5 == 0){
sum += i;
count++;
}
}
System.out.println("sum : " + (int)sum);
System.out.printf("avg : %.1f",sum/count);
}
}
형성평가7
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
for(int i = 1; i <= 10; i++) System.out.print((i*a) + " ");
}
}
형성평가8
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++) {
System.out.print((i*j) + " ");
}
System.out.println();
}
}
}
형성평가9
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
for(int i = 1; i <= a; i++){
for(int j = 1; j <= a; j++){
System.out.printf("(%d, %d) ", i, j);
}
System.out.println();
}
}
}
형성평가10
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
if(a>b){
for(int j = 1; j < 10; j++){
for (int i = a; i >= b; i--){
System.out.printf("%d * %d =%3d ", i, j, i*j);
}
System.out.println();
}
}
else{
for(int j = 1; j < 10; j++){
for (int i = a; i <= b; i++){
System.out.printf("%d * %d =%3d ", i, j, i*j);
}
System.out.println();
}
}
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 140 ~ 149 : 반복제어문3 - 형성평가1 ~ 10 (0) | 2023.09.27 |
---|---|
[자바] 정올 549 ~ 553 && 634 : 반복제어문3 - 자가진단 1 ~ 7 (0) | 2023.09.27 |
[자바] 정올 541 ~ 548 : 반복제어문2 - 자가진단 1 ~ 8 (0) | 2023.09.26 |
[자바] 정올 129 : 반복제어문1 - 형성평가5 (0) | 2023.09.25 |
[자바] 정올 128 : 반복제어문1 - 형성평가4 (0) | 2023.09.25 |