當前位置:編程學習大全網 - 編程軟體 - 如何編程,在屏幕上輸出2010年的年歷

如何編程,在屏幕上輸出2010年的年歷

#include <iostream>

#include <vector>

#include <iomanip> / tw()的頭文件

using namespace std;

bool IsLeapYear(int year) //判斷是否是閏年

{

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

return true;

else

return false;

}

void main()

{

int year,month,a[31];

cout<<"請輸入年:";

cin>>year;

cout<<"請輸入月:";

cin>>month;

if(month==2)

{

if(IsLeapYear(year)==true) //是閏年

{

for(int i=1; i<=28; i++)

{

cout<<setw(4)<<(a[i]=i);

if(i%7==0) cout<<endl;

}

cout<<endl;

}

else //不是閏年

{

for(int i=1; i<=29; i++)

{

cout<<setw(4)<<(a[i]=i);

if(i%7==0) cout<<endl;

}

cout<<endl;

}

}

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

{

for(int i=1; i<=30; i++)

{

cout<<setw(4)<<(a[i]=i);

if(i%7==0) cout<<endl;

}

cout<<endl;

}

else

{

for(int i=1; i<=31; i++)

{

cout<<setw(4)<<(a[i]=i);

if(i%7==0) cout<<endl;

}

cout<<endl;

}

}

有什麽不明白的,在線問我

  • 上一篇:unity ngui怎麽做視頻播放進度條怎麽賦值
  • 下一篇:濟南翼菲自動化有限公司是個怎樣的單位?
  • copyright 2024編程學習大全網