1 条题解

  • 0
    @ 2024-8-27 21:16:47
    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    using namespace std;
    int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int main()
    {
    	int n,m;
    	cin >> n >> m;
    	int sum = 0;
    	int yy,mm;
    	yy = 1900;
    	while(yy < n)
    	{
    		if(yy%4 == 0 && yy%100 != 0)
    		   sum += 366;
    		else if(yy%400 == 0)
    		   sum += 366;
    		else
    		   sum += 365;
    		yy++;
    	} 
    	mm = 1;
    	while(mm < m)
    	{
    		sum += month[mm];
    		mm++;
    	}
    	int num = month[m];
    	if(m > 2)
    	    if((n%4 == 0 && n%100 != 0 ) || (n %400 == 0))
    	   	    sum++;
       	if(m == 2)
            if((n%4 == 0 && n%100 != 0 ) || (n%400 == 0))
                num++;
    	sum = sum % 7;
    	cout << "Sun Mon Tue Wed Thu Fri Sat\n";
    	if(sum != 6)
    	    for(int i = 0 ; i <= sum ; i++)
    	        cout << "    ";
    	for(int i = 1 ; i <= num ; i++)
    	{
    	   	printf("%3d ",i);
    	   	if( (i+sum) %7 == 6)
    	   	    cout << endl;
    	}
        return 0;
    }
    
    • 1

    信息

    ID
    2771
    时间
    1000ms
    内存
    256MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者