標題:
[作業] 猜拳遊戲 (二)
[打印本頁]
作者:
鄭繼威
時間:
2022-12-14 00:13
標題:
[作業] 猜拳遊戲 (二)
本帖最後由 鄭繼威 於 2023-6-2 17:48 編輯
以陣列存放 "剪刀" "石頭" "布",改寫上一個程式-
猜拳遊戲 (一)
。
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
string n[]={"剪刀","石頭","布"};
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1; //1~3
cout<<"你出"<<n[player-1]<<endl;
cout<<"電腦出"<<n[computer-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃裕恩
時間:
2022-12-17 10:20
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
string n[]={"剪刀","石頭","布"};
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1; //1~3
cout<<"你出"<<n[player-1]<<endl;
cout<<"電腦出"<<n[computer-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林劭澧
時間:
2022-12-17 16:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,conputer;
string n[]={"剪刀","石頭","布"};
cout<<"請出拳(1)剪刀 (2)石頭 (3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出"<<n[player-1]<<endl;
cout<<"電腦出"<<[computer-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林劭杰
時間:
2022-12-28 19:48
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
string n[]={"剪刀","石頭","布"};
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出"<<n[player-1]<<endl;
cout<<"電腦出"<<n[computer-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
李彣
時間:
2022-12-28 19:52
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player, computer;
string n[]={"剪刀","石頭","布"};
cout<<"請出拳(1)剪刀(2)石頭(3)布:";
cin>>player;
computer=rand()%3+1;
cout<<"玩家出"<<n[player-1]<<endl;
cout<<"電腦出"<<n[computer-1]<<endl;
computer=rand()%3+1;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2