演算法學習之路 乙個簡單的多行萬年曆

2021-09-20 23:52:42 字數 849 閱讀 8834

題目簡介:乙個入門級的小專案。

多行萬年曆

輸入乙個年份+行數

以每行n個輸出萬年曆形式的月份

詳情見**:

//多行萬年曆

//思路就是把輸入的每一年存入陣列中,再根據輸入行數格式化輸出

#include using namespace std;

bool isrui(int );//判斷是否為瑞年

int week(int );//判斷每年的第一天為週幾

int day(int month,int year);//判斷這個月多少天

int main();

cin>>year>>line;

for(int m=0,start=week(year);m<12;m++)

}//把輸入的年份所有天數存入陣列

for(int i=1;i<=12;i+=line)

cout<<" ";

}cout<}//按需輸出格式化天數

}return 0;

}int day(int month,int year)

if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)

else if(month==2&&isrui(year))

else if(month==2&&!isrui(year))

else

}int week (int year)

bool isrui(int year)

else

}

php製作萬年曆的步驟 製作乙個php萬年曆

1.獲取日期年和月,預設當前年份和月份 2.計算當前月份有多少天和本月1號是星期幾 3.輸出日期的頭部資訊 4.迴圈遍歷輸出輸出天數 1.year empty request y date y intval request y month empty request m date m intval ...

給你乙個極品萬年曆

0x8 i 1 sum lunarinfo y 1900 i 1 0 return sum leapdays y 傳回農曆 y年閏月的天數 function leapdays y 傳回農曆 y年閏哪個月 1 12 沒閏傳回 0 function leapmonth y 傳回農曆 y年m月的總天數 f...

製作乙個php萬年曆

1.獲取日期年和月,預設當前年份和月份 2.計算當前月份有多少天和本月1號是星期幾 3.輸出日期的頭部資訊 4.迴圈遍歷輸出輸出天數 1.year empty request y date y intval request y month empty request m date m intval ...