5 条题解

  • 3
    @ 2024-11-17 18:09:00
    #include <bits/stdc++.h>
    using namespace std;
    int a,b,c = 1,week = 1,day;
    int main(){
    	cin >> a >> b;
    	for(int i = 1900,j = 1,k = 1 ;  ; k++,week = week % 7 + 1){
    		if((j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12) && k == 32) j++,k = 1;
    		if((j == 4 || j == 6 || j == 9 || j == 11) && k == 31) j++,k = 1;
    		if(((i % 400 == 0 || (i % 100 != 0 && i % 4 == 0)) && j == 2 && k == 30) || (!((i % 400 == 0 || (i % 100 != 0 && i % 4 == 0))) && j == 2 && k == 29)) j++,k = 1;
    		if(j == 13) i++,j = 1;
    		if(i == a && j == b && k == c) break;
    	}
    	if(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12) day = 31;
    	if(b == 4 || b == 6 || b == 9 || b == 11) day = 30;
    	if((a % 400 == 0 || (a % 100 != 0 && a % 4 == 0)) && b == 2) day = 29;
    	if(!((a % 400 == 0 || (a % 100 != 0 && a % 4 == 0))) && b == 2) day = 28;
    	cout << "Sun Mon Tue Wed Thu Fri Sat\n";
    	for(int i = 1 ; i <= week * 4 ; i++) cout << " ";
    	for(int i = 1 ; i <= day ; i++,week = week % 7 + 1){
    		if(week == 7) cout << endl;
    		cout << setw(3) << i << " ";
    	}
    	return 0;
    }
    
    • 0
      @ 2024-11-22 19:52:03
      #include < iostream>
      #include <string.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";
      int p=sum;
      if(sum!=6){
      for(int i=0;i<=sum;i++){
      cout<<"    ";
      }
      }
      for(int i=1;i<=num;i++){
      printf("%3d",i);
      cout<<" ";
      if((i+sum)%7==6) cout<<endl;
      }
      return 0;
      }
      
      
      
      • -2
        @ 2022-11-11 23:48:56

        #include<iostream>
        using namespace std;
        int bgyear,bgmonth,bgday;
        int enyear,enmonth,enday;
        int month[21]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        int rmonth[21]={0,31,29,31,30,31,30,31,31,30,31,30,31};
        int flag=1;
        int tot=0;
        int dow=1;
        string week[8]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
        int main(){
        cin>>enyear>>enmonth;
        bgyear=1900;
        bgmonth=1;
        bgday=1;
        for(int i=1900;i<=enyear;i++){
        if((i%40&&i%100!=0)||(i%4000)){
        for(int j=1;j<=12;j++){
        for(int k=1;k<=rmonth[j];k++){
        if(ienyear&&jenmonth){
        int bj=0;
        cout<<"Sun Mon Tue Wed Thu Fri Sat"<<endl;
        for(int i=1;i<=dow;i++){
        if(dow7)break;
        bj++;
        for(int i=1;i<=3;i++)
        cout<<" ";
        cout<<" ";
        }
        for(int k=1;k<=rmonth[j];k++){
        if(k<10){
        if(bj!=6&&k!=rmonth[j])
        cout<<" "<<k<<" ";
        else{
        cout<<" "<<k;
        }
        bj++;
        if(bj
        7){
        cout<<endl;
        bj=0;
        }
        }
        else{
        if(bj!=6&&k!=rmonth[j]) cout<<" "<<k<<" "; else { cout<<" "<<k; } if(krmonth[j])return 0; bj++; if(bj7) { cout<<endl; bj=0; } } } return 0; }//边界条件 dow++; if(dow8) dow=1; } } }//闰年 else { for(int j=1;j<=12;j++) { for(int k=1;k<=month[j];k++) { if(ienyear&&jenmonth) { int bj=0; cout<<"Sun Mon Tue Wed Thu Fri Sat"<<endl; for(int i=0;i<=dow-1;i++) { if(dow7)break; if(bj6)break; bj++; for(int i=1;i<=3;i++) cout<<" "; cout<<" "; }//确定第一个数的位置 for(int k=1;k<=month[j];k++) { if(k<10) { if(bj!=6&&k!=month[j]) cout<<" "<<k<<" "; else { cout<<" "<<k; } bj++; if(bj7) { cout<<endl; bj=0; } } else { if(bj!=6&&k!=month[j]) cout<<" "<<k<<" "; else { cout<<" "<<k; } bj++; if(bj7) { cout<<endl; bj=0; } if(kmonth[j])return 0; } } return 0; }//边界条件 dow++; if(dow==8) dow=1; } } } } }

        • -4
          @ 2024-8-27 21:14:55
          #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;
          }
          
          • -4
            @ 2022-9-17 15:45:05

            #include <queue> #include <stack> #include <vector> #include <math.h> #include <iomanip> #include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N=1e6+10; const int INF=0x3f3f3f3f; 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 nn,mm; nn=1900; while(nn<n) { if(nn%40&&nn%100!=0) sum+=366; else if(nn%4000) sum+=366; else sum+=365; nn++; } mm=1; while(mm<m) { sum+=month[mm]; mm++; } int num=month[m]; if(m>2) { if((n%40&&n%100!=0)||(n%4000)) sum++; } if(m2) { if((n%40&&n%100!=0)||(n%4000)) 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)%76) cout<<endl; } return 0; }

            • 1

            信息

            ID
            1090
            时间
            1000ms
            内存
            128MiB
            难度
            7
            标签
            递交数
            226
            已通过
            51
            上传者