SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int P=sc.nextInt();
int K=sc.nextInt();
int score=0;
for(int test_case = 0; P>K; test_case++)
{
score = score +1;
K = K + 1;
if(P==K)
break;
}
System.out.println(score+1);
}
}
굳이 문제 풀 때 할 필요는 있나? 생각하지만 P가 K보다 같거나 작은 경우라던가 하면 오류 메시지 출력을 한다거나 해야겠습니다
'SWEA' 카테고리의 다른 글
[SWEA] 대각선 출력하기 (0) | 2024.09.19 |
---|---|
[SWEA] 몫과 나머지 출력하기 (0) | 2024.09.19 |
[SWEA] 스탬프 찍기 (1) | 2024.09.13 |
[SWEA] 신문 헤드라인 (0) | 2024.09.13 |
[SWEA] 알파벳을 숫자로 변환 (0) | 2024.09.13 |