728x90
반응형
SMALL
형성평가1
public class Main {
public static void main(String[] args) {
System.out.println("first");
pr();
System.out.println("second");
pr();
System.out.println("third");
pr();
}
public static void pr(){
System.out.println("@@@@@@@@@@");
}
}
형성평가2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a =sc.nextInt();
int answer = addAll(a);
System.out.println(answer);
}
public static int addAll(int n){
int a = 0;
for(int i = 0; i <= n; i++) a+=i;
return a;
}
}
형성평가3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
pr(a);
}
public static void pr(int a) {
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= a; j++) {
System.out.print((i*j) + " ");
}
System.out.println();
}
}
}
형성평가4
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 answer = an(a,b);
System.out.println(answer);
}
public static int an(int a, int b){
int max = a > b ? a : b;
int min = a < b ? a : b;
return (int)(Math.pow(max, 2) - Math.pow(min, 2));
}
}
형성평가5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] arr = new int[3][3];
for(int i = 0; i < arr.length; i++){
for(int j = 0; j < arr[i].length; j++){
arr[i][j] = sc.nextInt();
}
}
pr_answer(arr);
}//end main
public static void pr_answer(int[][] arr){
int sum = 0, total = 0;
int[] col = new int[3];
for(int i = 0; i < arr.length; i++){
for(int j = 0; j < arr[i].length; j++){
System.out.print(arr[i][j] + " ");
col[j] += arr[i][j];
sum += arr[i][j];
}
total += sum;
System.out.println(sum);
sum = 0;
}
for(int i = 0; i < col.length; i++){
System.out.print(col[i] + " " );
}
System.out.println(total);
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 175 ~ 181 : 함수2 - 형성평가1~7 (0) | 2023.10.03 |
---|---|
[자바] 정올 579 ~ 586 : 함수2 - 자가진단1~8 (0) | 2023.10.03 |
[자바] 정올 571 ~ 578 : 함수1 - 자가진단1 ~ 8 (1) | 2023.10.01 |
[자바] 정올 160 ~ 169 : 배열2 - 형성평가1 ~ 10 (0) | 2023.09.30 |
[자바] 정올 564 ~ 570 : 배열2 - 자가진단1 ~ 7 (0) | 2023.09.30 |