A题不分早晚!
第一道枚举水题
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int p,e,i,d;
int m =1;
while((p=sc.nextInt())!=-1&&(e=sc.nextInt())!=-1&&(i=sc.nextInt())!=-1&&(d=sc.nextInt())!=-1){
sc.nextLine();
int x = d+1;
for(;x<=21252;x++){
if((x-p)%23==0)
break;
}
for(;x<=21252;x+=23){
if((x-e)%28==0)
break;
}
for(;x<=21252;x+=28*23){
if((x-i)%33==0)
break;
}
System.out.println("Case "+(m++)+": the next triple peak occurs in "+(x-d)+" days.");
}
}
}
本文介绍了一道关于枚举算法的编程题目,通过Java实现了一个具体的解决方案。该程序使用了多个循环来找出符合特定条件的日期,展示了如何处理复杂的日期计算问题。
1万+

被折叠的 条评论
为什么被折叠?



