中级天翼
核心
int y1=2019,m1=10,d1=1,xq=2;
cin>>y>>m;
if(y>2019||y==2019&&m>=10){
while(!(y1==y&&m1==m&&d1==d)){
d1++;
if(d1>a[m1]){
d1=1;
m1++;
if(m1>12){
m1=1;
y1++;
if(y1%4==0&&y1%100!=0||y1%400==0){
a[2]=29;
}
else{
a[2]=28;
}
}
}
xq++;
if(xq>7){
xq=1;
}
}
}
else{
while(!(y1==y&&m1==m&&d1==d)){
d1--;
if(d1==0){
m1--;
if(m1==0){
m1=12;
y1--;
if(y1%4==0&&y1%100!=0||y1%400==0){
a[2]=29;
}
else{
a[2]=28;
}
}
d1=a[m1];
}
xq--;
if(xq==0){
xq=7;
}
}
}
cout<<"Sun Mon Tue Wed Thu Fri Sat"<<endl;
这是暑假作业吗??你没有讲义吗??
1
1
for(int i=1;i<=xq%7;i++){
cout<<" ";
}
for(int i=1;i<=a[m];i++){
cout<<setw(3)<<i<<" ";
if(xq==6){
cout<<endl;
}
xq++;
if(xq>7){
xq=1;
}
}
中级光能
核心:
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int y[13]={0,3,0,3,2,3,2,3,3,2,3,2,3};
int main(){
int i,n,l=1,year,f=0,m;
cin>>year>>m;
if((year%4==0&&year%100!=0)||(year%400==0)){
month[2]=29;
y[2]=1;
}
cout<<"Sun Mon Tue Wed Thu Fri Sat"<<endl;
l=l+(year-1900)+((year-1900)/4);
for(i=1;i<=m;i++){
l=l+y[i-1];
if(l>=7) l=l%7;
}
if(y[2]==1) l=l-1;
for(i=1;i<=l;i++){
cout<<" ";
f++;
}
}