標題:
[隨堂測驗] 生肖判斷
[打印本頁]
作者:
方浩葦
時間:
2024-8-3 03:33
標題:
[隨堂測驗] 生肖判斷
請設計一程式,
能根據使用者輸入的西元年,回報該年是哪個生肖。
本帖隱藏的內容需要回復才可以瀏覽
作者:
林少謙
時間:
2024-8-3 16:21
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int x;
re:
cout<<"請輸入出生之西元年: ";
cin>>x;
x=x-1911;
x=x%12;
string a[]{"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"};
cout<<endl<<a[x-1]<<"年!"<<endl<<endl;
goto re;
}
複製代碼
作者:
李唯銘
時間:
2024-8-10 15:44
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int x;
re:
cout<<"請輸入出生之西元年: ";
cin>>x;
x=x-1911;
x=x%12;
string a[]{"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"};
cout<<endl<<a[x-1]<<"年!"<<endl<<endl;
goto re;
}
複製代碼
作者:
劉奕劭
時間:
2024-8-10 16:16
#include<iostream>
#include<cstdlib>
#include <ctime>
using namespace std;
int main()
{
int t;
cout<<"請輸入出生西元年: ";
cin>>t;
t=t-1911;
t=t%12;
string a[]{"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"};
cout<<endl<<a[t-1]<<"年"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-8-11 17:20
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int x;
re:
cout<<"請輸入西元年: ";
cin>>x;
x=x-1911;
x=x%12;
string a[]{"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"};
cout<<endl<<a[x-1]<<"年!"<<endl<<endl;
goto re;
}
複製代碼
作者:
陳妍蓁
時間:
2024-8-16 22:00
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int y;
re:
cout<<"請輸入西元年:"<<endl;
cin>>y;
y=y-1911;
y=y%12;
string n[]={"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"};
cout<<n[y-1]<<"年"<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2