1.题目详情:
package shanxiligongdaxue; import java.util.Scanner; public class TianTiSai3 {//7-3 今天后的第n天是星期几 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int n = sc.nextInt(); if (n >7) { int r = (n) % 7; switch (r) { case 0: System.out.println(7); break; case 1: System.out.println(a + 1); break; case 2: System.out.println(a + 2); break; case 3: System.out.println(a + 3); break; case 4: System.out.println(a + 4); break; case 5: System.out.println(a + 5); break; case 6: System.out.println(a + 6); } } else if (n<-7){ int r=Math.abs((n)%7);// if(a-r>0) { switch (r) { case 0: System.out.println(7); break; case 1: System.out.println(a - r); break; case 2: System.out.println(a - r); break; case 3: System.out.println(a - r); break; case 4: System.out.println(a - r); break; case 5: System.out.println(a - r); break; case 6: System.out.println(a - r); } }else if (a-r<0){ System.out.println(a-r+7); } }else if (n<=7&&n>0&&a+n<=7){ System.out.println(a+n); }else if (n<=7&&n>0&&a+n>7){ System.out.println((a+n)-7); }else if (n==0){ System.out.println(a); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)