已知 2007/1/1 是星期一 ( 不是用程式算的 )
目前輸出是由 1 月 向下到 12 月 ( 老師要求是要 123 456 789 101112 分四排 )
#include<iostream>
using namespace std;
int main(){
int w,k;
w=1;
for(int m=1;m<=12;m++){
if(m==1||m==3||m==5||m==7||m==8||m==10) k=31;
if(m==4||m==6||m==9||m==11) k=30;
if(m==2) k=28;
cout<<" S M T W T F S\n";
for(int a=0;a<w;a++) cout<<" ";
for(int a=1;a<=k;a++){
if(a<10) cout<<" "<<a<<" "; else cout<<a<<" ";
w++;
if(w==7){
w=0;
cout<<"\n";
}
}
cout<<"\n";
}
system("pause");
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.240.186.34