3 条题解
-
0117爱好者 (mengqingyu) LV 10 @ 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; }
-
02022-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(bj7){
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; } } } } } -
02022-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
- 标签
- 递交数
- 144
- 已通过
- 28
- 上传者