標題:
月曆產生器 (二)
[打印本頁]
作者:
王瑞喻
時間:
2020-6-12 11:29
標題:
月曆產生器 (二)
本帖最後由 王瑞喻 於 2020-6-13 15:41 編輯
2020年 月曆
本帖隱藏的內容需要回復才可以瀏覽
本帖隱藏的內容需要積分高於 10 才可瀏覽
作者:
鐘彥博
時間:
2020-6-13 20:26
本帖最後由 鐘彥博 於 2020-6-25 20:59 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int a,b,mou;
cout<<"[2020年月曆]"<<endl;
cout<<endl;
cout<<"請輸入想知道的月份(1~12):";
cin>>mou;
cout<<endl;
switch(mou)
{
case 1:
b=4;a=31;
break;
case 2:
b=7;a=29;
break;
case 3:
b=1;a=31;
break;
case 4:
b=4;a=30;
break;
case 5:
b=6;a=31;
break;
case 6:
b=2;a=30;
break;
case 7:
b=4;a=31;
break;
case 8:
b=7;a=31;
break;
case 9:
b=3;a=30;
break;
case 10:
b=5;a=31;
break;
case 11:
b=1;a=30;
break;
case 12:
b=3;a=31;
break;
default:
cout<<"Please try to read what I wrote on the screen!"<<endl;
system("pause");
goto re;
}
cout<<"日\t一\t二\t三\t四\t五\t六"<<endl;
for(int j=1;j<=a+b-1;j++)
{
if(j<b)
{
cout<<" \t";
}else
{
cout<<j-(b-1)<<" \t";
}
if(j%7==0)
{
cout<<endl;
}
}
cout<<endl;
cout<<endl;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
謝承志
時間:
2020-7-4 16:00
本帖最後由 謝承志 於 2020-7-4 16:49 編輯
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
re:
int month,start,days;
cout<<"【 2020年月曆查詢 】"<<endl<<endl;
cout<<"請輸入欲查詢的月份(1~12): ";
cin>>month;
cout<<endl;
switch(month)
{
case 1:
start=4;days=31;
break;
case 2:
start=7;days=29;
break;
case 3:
start=1;days=31;
break;
case 4:
start=4;days=30;
break;
case 5:
start=6;days=31;
break;
case 6:
start=2;days=30;
break;
case 7:
start=4;days=31;
break;
case 8:
start=7;days=31;
break;
case 9:
start=3;days=30;
break;
case 10:
start=5;days=31;
break;
case 11:
start=1;days=30;
break;
case 12:
start=3;days=31;
break;
default:
cout<<"輸入錯誤,請重新輸入"<<endl;
goto re;
}
cout<<"日\t一\t\二\t三\t四\t五\t六"<<endl;
for(int a=1;a<=start+days-1;a++)
{
if(a<start)
{
cout<<" \t";
}
else
{
cout<<a-start+1<<" \t";
}
if(a%7==0)
cout<<endl;
}
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
董定宇
時間:
2020-7-4 17:28
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int days, start, month;
cout<<"【 2020年月曆查詢 】"<<endl<<endl;
cout<<"請輸入欲查詢的月份(1~12): ";
cin>>month;
switch(month)
{
case 1 :
days=31,start=4;
break;
case 2 :
days=29,start=7;
break;
case 3 :
days=31,start=1;
break;
case 4 :
days=30,start=4;
break;
case 5 :
days=31,start=6;
break;
case 6 :
days=30,start=2;
break;
case 7 :
days=31,start=6;
break;
case 8 :
days=31,start=7;
break;
case 9 :
days=30,start=3;
break;
case 10 :
days=31,start=5;
break;
case 11 :
days=30,start=1;
break;
case 12 :
days=31,start=3;
break;
default :
cout<<"輸入錯誤,請重新輸入!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"日\t一\t二\t三\t四\t五\t六"<<endl;
for(int i=1; i<=days+(start-1); i++)
{
if(i<start)
{
cout<<" \t";
}
else
{
cout<<i-(start-1)<<"\t";
}
if(i%7==0)
cout<<endl;
}
cout<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
潘堉恩
時間:
2020-7-4 17:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int x,y,z;
cout<<"[2020年月曆]"<<endl;
cout<<endl;
cout<<"請輸入想知道的月份(1~12):";
cin>>z;
cout<<endl;
switch(z)
{
case 1:
y=4;x=31;
break;
case 2:
y=7;x=29;
break;
case 3:
y=1;x=31;
break;
case 4:
y=4;x=30;
break;
case 5:
y=6;x=31;
break;
case 6:
y=2;x=30;
break;
case 7:
y=4;x=31;
break;
case 8:
y=7;x=31;
break;
case 9:
y=3;x=30;
break;
case 10:
y=5;x=31;
break;
case 11:
y=1;x=30;
break;
case 12:
y=3;x=31;
break;
default:
cout<<"請嘗試閱讀我在屏幕上寫的內容!"<<endl;
system("pause");
goto re;
}
cout<<"日\t一\t二\t三\t四\t五\t六"<<endl;
for(int j=1;j<=x+y-1;j++)
{
if(j<y)
{
cout<<" \t";
}else
{
cout<<j-(y-1)<<" \t";
}
if(j%7==0)
{
cout<<endl;
}
}
cout<<endl;
cout<<endl;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
李柏穎
時間:
2020-7-4 17:37
本帖最後由 李柏穎 於 2020-7-10 22:57 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int days, start, month;
cout<<"【 2020月曆查詢 】"<<endl<<endl;
cout<<"請輸入要查詢的月份(1~12): ";
cin>>month;
switch(month)
{
case 1:
days=31,start=4;
break;
case 2:
days=29,start=7;
break;
case 3:
days=31,start=1;
break;
case 4:
days=30,start=4;
break;
case 5:
days=31,start=6;
break;
case 6:
days=30,start=2;
break;
case 7:
days=31,start=4;
break;
case 8:
days=31,start=7;
break;
case 9:
days=30,start=3;
break;
case 10:
days=31,start=5;
break;
case 11:
days=30,start=1;
break;
case 12:
days=31,start=3;
break;
default:
cout<<"輸入錯誤,重新輸入"<<endl;
system("pause");
goto re;
}
cout<<endl<<"日\t一\t二\t三\t四\t五\t六"<<endl;
for(int i=1; i<=days+(start-1); i++)
{
if(i<start)
{
cout<<" \t";
}
else
{
cout<<i-(start-1)<<" \t";
}
if(i/7==0)
cout<<endl;
}
cout<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2