C 做的乙個萬年曆

2021-09-24 11:46:36 字數 1367 閱讀 7080

實現輸出乙個年份後,輸出這個年份的月份、星期、日期;

編碼工具:vs2015

下面是**:

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace 萬年曆

年月\n", currentyear, i);

console.writeline("一   二   三   四   五   六   日");

console.writeline("---------------------------------");

index = x;

int monthindex2 = 1;//每個月預設從第一天開始

while (monthindex2<=y)

for (int k = index; k <=7; k++)

if (monthindex2<=9)

else

monthindex2++;

}console.writeline();

index = 1;

}console.writeline("\n\n");

}console.readkey();

}static bool isleapyear(int year)//判斷某年是不是閏年

else

}static int whatday(int currentyear,int month)//判斷從某年某月第一天是星期幾

else

}for (int j = 1; j < month; j++)

num = totaldays % 7;

return num + 1;

}static int everymonthdays(int year, int month)//判斷某年每個月的天數

else if (i == 4 || i == 6 || i == 9 || i == 11)

else if (i == 2 && isleapyear(year) == true)

else

return monthday;}}

}下面是效果截圖:

C實現萬年曆

要求 輸入年份輸出這一年的日曆 注意 公元1900年一月一日是星期一,這一年是平年 思路 獲取輸入的年份y,首先獲取從公元1900年到 y 1 年 的天數,然後獲得該年份的第一天是星期幾,進行輸出。這次例項,我花費了很長的時間,最後發現錯誤的原因出在在求某一年是閏年還是平年的時候,我沒有田間retu...

萬年曆 C語言

顯示效果 大概步驟 1.顯示主介面 void showmenu char temp 10 2.判斷是否為閏年 bool isleap int year 3.計算總天數 int daysum int year,int month 4.顯示日曆 showcalendar int sum,int year...

簡易萬年曆

div設定 li body calendar calendar ul calendar li calendar li h2 calendar li p calendar active calendar active p calendar text calendar text h2 calendar ...