-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnail.java
More file actions
37 lines (30 loc) Β· 808 Bytes
/
Copy pathSnail.java
File metadata and controls
37 lines (30 loc) Β· 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package quiz;
import java.util.Scanner;
public class Snail {
public static void main(String[] args) {
int len; //λ무μ λμ΄
int up; //μ¬λΌκ°λ λμ΄
int down; // λ―Έκ·Έλ¬μ§λ λμ΄
int now = 0; //νμ¬ λμ΄
int day = 1;
Scanner scanner = new Scanner(System.in);
System.out.println("ν루μ μ¬λΌκ°λ λμ΄ μ
λ ₯");
up = scanner.nextInt();
System.out.println("λ°€μ λ―Έλλ¬μ§λ λμ΄ μ
λ ₯");
down = scanner.nextInt();
System.out.println("λ무μ λμ΄ μ
λ ₯");
len = scanner.nextInt();
while(true) {
now += up;
if(len <= now) {
break;
}
now -= down;
if(now < 0) {
now = 0;
}
day++;
}
System.out.println("λ무λ₯Ό μ¬λΌκ°λλ° κ±Έλ¦¬λ λ : " + day);
}
}