解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int w = input.nextInt(); // 一月一日星期几 int[] daysInMonth={0,31,28,31,30,31,30,31,31,30,31,30,31}; int unluckNumber=0; for(int month=1;month<=12;month++){ if((w+12)%7==5){ System.out.println(month); unluckNumber++; } w=(w+daysInMonth[month])%7; } if(unluckNumber==0){ System.out.println("无"); } } }
0.0分
1 人评分