复制代码,输入月份,得知日期

#include <bits/stdc++.h>
typedef long long ll;
#define int long long
const int N=1e6+1e7;
using namespace std;
int n,x,day;
signed main(){
	cin>>n;
	if(n==1){
		x=4,day=31;
	}else if(n==2){
		x=7,day=28;
	}else if(n==3){
		x=7,day=31;
	}else if(n==4){
		x=3,day=30;
	}else if(n==5){
		x=5,day=31;
	}else if(n==6){
		x=1,day=30;
	}else if(n==7){
		x=3,day=31;
	}else if(n==8){
		x=6,day=31;
	}else if(n==9){
		x=2,day=30;
	}else if(n==10){
		x=3,day=31;
	}else if(n==11){
		x=7,day=30;
	}else if(n==12){
		x=2,day=31;
	}
	cout<<"MON TUE WED THU FRI SAT SUN\n";
	for(int i=1;i<x;i++){
		cout<<"    ";
	}
	for(int i=1;i<=day;i++){
		int m=(i+x-1)%7;
		if(m==0)m=7;
		if(i<10){
			cout<<"  ";
		}else{
			cout<<" ";
		}
		cout<<i<<" ";
		if(m==7)cout<<"\n"; 
	}
	return 0;
}

记得点赞🤮🤮🤮

2 条评论

  • 1