728x90
반응형
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
//입력 받은 정수를 저장할 num 선언
int num;
//while문의 제어 변수 check를 true로 선언
boolean check = true;
while(check){
//입력된 정수를 num에 저장
num = sc.nextInt();
if(num==0){
check = false;
} else{
System.out.println(num);
}
}
sc.close();
}
}
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
int num;
for(int i=0;i<count;i++){
//count 개의 정수를 입력
num = sc.nextInt();
System.out.println(num);
}
sc.close();
}
}
//자바코드
import java.util.Scanner;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
//입력 받은 정수를 저장할 num 선언
int num;
//while문의 제어 변수 check를 true로 선언
boolean check = true;
while(check){
//입력된 정수를 num에 저장
num = sc.nextInt();
if(num==0){
check = false;
} else{
System.out.println(num);
}
}
sc.close();
}
}
728x90
반응형
'Coding Test > CodeUp' 카테고리의 다른 글
CodeUp_Java 기초 100제 - [기초-종합] 78~86 (0) | 2022.02.14 |
---|---|
CodeUp_Java 기초 100제 - [기초-반복실행구조] 74~77 (0) | 2022.02.14 |
CodeUp_Java 기초 100제 - [기초-조건/선택실행구조] 월 입력받아 계절 출력하기 70 (0) | 2022.02.13 |
CodeUp_Java 기초 100제 - [기초-조건/선택실행구조] 평가 입력받아 다르게 출력하기 69 (0) | 2022.02.13 |
CodeUp_Java 기초 100제 - [기초-조건/선택실행구조] 정수 1개 입력받아 평가 출력하기 68 (0) | 2022.02.13 |
댓글