ccf201812-2小明放学JAVA求解

我的代码为啥输出不了数据
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int r = scanner.nextInt();
int y = scanner.nextInt();
int g = scanner.nextInt();
int n = scanner.nextInt();
int time = 0;
for(int i = 0;i<n;i++) {
int k =scanner.nextInt();
int t =scanner.nextInt();
int dex = time;
while(t-dex<=0){
if(k==1){k=3;dex-=t;t=g;}
if(k==2){k=1;dex-=t;t=r;}
if(k==3){k=2;dex-=t;t=y;}
}
if(dex!=0){
t-=dex;
dex = 0;
}
if(k==0) {
time+=t;
}else if(k==1) {
time+=t;
}
else if(k==2) {
time+=t+r;
}else {
time+=0;
}
}
System.out.println(time);
}}

第1个回答  2019-03-16
恩,这代码是我见过最厉害的写法...
这么写,难道不怕编译器跟电脑爆炸?
请问尊师是谁?
我也想学习一下,这同样的拳法......


Warning: Invalid argument supplied for foreach() in /www/wwwroot/www.t2y.org3v3b34/skin/templets/default/contents.html on line 47
相似回答