728x90
반응형
SMALL
자가진단1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0, count = 0, n = sc.nextInt();
for(int i = 1; i <= n; i++){
if(sum >= n) break;
if(i%2 != 0) {
count++;
sum += i;
}
}//end for
System.out.println(count + " " + sum);
}
}
자가진단2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
String star = "*";
for(int i = 1; i <= a; i++){
System.out.println(star.repeat(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();
String star = "*";
for(int i = a; i >= 1; i--){
System.out.println(star.repeat(i));
}
for(int i = 1; i <=a; i++){
System.out.println(star.repeat(i));
}
}
}
자가진단4
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String star = "*";
String blank = " ";
for(int i=0; i<n; i++){
System.out.print(blank.repeat(i));
System.out.println(star.repeat(n-i));
}
}
}
자가진단5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int d = 2*n -1;
String star = "*";
String blank = " ";
for(int i=0; i<n; i++){
System.out.print(blank.repeat(i));
System.out.print(star.repeat(d- 2*i));
System.out.println(blank.repeat(i));
}
}
}
자가진단6
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int init = 64;
String str = "";
for(int i = n; i >= 1; i--){
for(int j = 1; j <= i; j++){
str += (char)(init + j);
}
System.out.println(str);
str = "";
init += i;
}
}
}
자가진단7
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int init_char = 64;
int init = 0;
String str = "";
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n + 1 -i; j++) {
init++;
System.out.print((init) + " ");
}
for(int k = 1; k <= i; k++){
init_char++;
System.out.print((char)(init_char) + " ");
}
System.out.println();
}
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 555 ~ 563 : 배열1 - 자가진단 1 ~ 9 (0) | 2023.09.27 |
---|---|
[자바] 정올 140 ~ 149 : 반복제어문3 - 형성평가1 ~ 10 (0) | 2023.09.27 |
[자바] 정올 130 ~ 139 : 반복제어문2 - 형성평가1 ~ 10 (0) | 2023.09.26 |
[자바] 정올 541 ~ 548 : 반복제어문2 - 자가진단 1 ~ 8 (0) | 2023.09.26 |
[자바] 정올 129 : 반복제어문1 - 형성평가5 (0) | 2023.09.25 |