最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

c++任意年月歷代碼

2022-03-16 10:48 作者:大威的水杯  | 我要投稿

代碼如下:

#include<iostream>

#include<conio.h>

#include<stdio.h>

using namespace std;


void calendar(int iyear, int imonth)

{

int i = 1900,blank=0,flag1,flag2=0;

int day = 0,mday;

//計(jì)算每月1日星期幾

while (i < iyear)

{

if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)

day += 366;

else

day += 365;

i++;

}

if (imonth == 2)

day += 31;

if (imonth == 3)

day += 31 + 28;

if (imonth == 4)

day += 31 + 28 + 31;

if (imonth == 5)

day += 31 + 28 + 31 + 30;

if (imonth == 6)

day += 31 + 28 + 31 + 30 + 31;

if (imonth == 7)

day += 31 + 28 + 31 + 30 + 31 + 30;

if (imonth == 8)

day += 31 + 28 + 31 + 30 + 31 + 30 + 31;

if (imonth == 9)

day += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31;

if (imonth == 10)

day += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30;

if (imonth == 11)

day += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;

if (imonth == 12)

day += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;

if ((iyear % 4 == 0 && iyear % 100 != 0 || iyear % 400 == 0) && (imonth > 2))

day += 1;

day = day % 7 + 1;

//1日前空格數(shù)量

blank += (day - 1) * 4;

//計(jì)算輸出月份的每月天數(shù)

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

mday = 31;

else

{

if (imonth == 2)

{

if (iyear % 4 == 0 && iyear % 100 != 0 || iyear % 400 == 0)

mday = 29;

else

mday = 28;

}

else

mday = 30;

}

//輸出部分

cout << "一? 二? 三? 四? 五? 六? 日" << endl;

for (flag1 = 0; flag1 < blank; flag1++)

cout << " ";

while (flag2 < mday)

{

if (flag2 < 9)

cout << flag2 + 1 << " ";

else

cout << flag2 + 1;

if (day == 7)

cout << endl;

else

cout << "? ";

flag2++;

day = (day + 1) % 7;

if (day == 0)

day = 7;

}

}


int main()

{

char cmd = 'Y';

int year, month;

while (1)

{

if (cmd == 'Y'||cmd=='y')

{

cout << "歡迎使用萬(wàn)年歷系統(tǒng)v1.0" << endl;

cout << "請(qǐng)輸入年份、月份:";

cin >> year >> month;

system("cls");

cout << "? ? ? ?" << year << "年? " << month << "月" << endl << endl;

calendar(year, month);

cout << endl << endl;

cout << "按任意鍵繼續(xù)..." << endl;

getchar();

getchar();//實(shí)現(xiàn)回車功能?

system("cls");

cout << "是否需要再次顯示其他月歷?(Y/N):";

cin >> cmd;

}

else

{

system("cls");

cout << "歡迎再次使用本系統(tǒng)!" << endl;

break;

}

if (cmd == 'Y' || cmd == 'y')

system("cls");

}

return 0;

}


c++任意年月歷代碼的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
襄汾县| 金塔县| 勃利县| 连城县| 安图县| 连平县| 聂荣县| 吴旗县| 长宁区| 阿鲁科尔沁旗| 永吉县| 绥棱县| 潞城市| 台东县| 吕梁市| 汝阳县| 齐河县| 遂溪县| 贺州市| 剑阁县| 平果县| 彝良县| 泰安市| 漯河市| 邹城市| 历史| 南部县| 青浦区| 岗巴县| 宁波市| 独山县| 岐山县| 浦江县| 织金县| 达拉特旗| 儋州市| 寿宁县| 舒兰市| 那坡县| 高州市| 社旗县|