標題:
猜拳遊戲 (二)
[打印本頁]
作者:
鄭繼威
時間:
2023-6-2 21:06
標題:
猜拳遊戲 (二)
以
陣列
存放 "剪刀" "石頭" "布",改寫上一個程式-
猜拳遊戲 (一)
。
#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;
}
複製代碼
作者:
蔡沛倢
時間:
2023-6-8 16:59
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int a,b;
string c[]={"剪刀","石頭","布"};
cout<<"請出拳 1剪刀2石頭3布";
cin>>a;
b=rand()%3+1;
cout<<"你出了"<<c[a-1]<<endl;
cout<<"電腦出了"<<c[b-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
呂宗晉
時間:
2023-6-9 17:24
#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;
}
複製代碼
複製代碼
作者:
何權晉
時間:
2023-6-9 20:47
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int p,c;
cout<<"ROCK PAPER SCISSORS 1v1 WITH PC!!"<<endl;
string n[]={"Rock!","Paper!","Scissors!"};
cout<<"Rock Paper Scissors! (1)Rock (2)Paper (3)Scissors";
cin>>p;
c=rand()%3+1;
cout<<"You picked: "<<n[p-1]<<endl;
cout<<"The PC Picked: "<<n[c-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
鄭繼威
時間:
2023-6-9 20:48
4
作者:
黃子豪
時間:
2023-6-9 20:49
#include<iostream>
#include<ctime>
using namespace std;
int main(){
srand(time(NULL));
int player, computer;
string a[3]={"剪刀", "石頭", "布"};
cout<<"請出拳! (1)剪刀(2)石頭(3)布";
cin>>player;
cout<<"你出"<<a[player-1]<<endl;
computer=rand()%3+1;
cout<<"電腦出"<<a[computer-1]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
廖秝瑜
時間:
2023-6-9 20:50
#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;
}
複製代碼
作者:
張絜晰
時間:
2023-6-9 20:52
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
srand(time(NULL));
int p,c;
string n[]={"剪刀","石頭","布"};
cout<<"請出拳:(1)剪刀(2)石頭(3)布";
cin>>p;
cout<<n[p-1]<<endl;
cout<<"電腦出:";
c=rand()%3+1;
cout<<n[c-1]<<endl;
system("pause");
return 0;}
複製代碼
作者:
呂得銓
時間:
2023-6-16 16:33
#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;
}
複製代碼
作者:
盧玄皓
時間:
2023-6-16 19:39
#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;
}
複製代碼
作者:
黃品禎
時間:
2023-7-1 16:42
#include<cstdlib>
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
string n[]={"剪刀","石頭","布"};
cout<<"你出"<<n[player-1] <<endl;
computer=rand()%3+1;
cout<<"電腦出"<<n[computer-1] <<endl;
system("pause");
return 0;
}
複製代碼
作者:
吳柏潁
時間:
2023-8-3 16:20
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int p,c;
string pss[]={"剪刀","石頭","布"};
srand(time(NULL));
cout<<"請出拳(1)剪刀(2)石頭(3)布:";
cin>>p;
cout<<"玩家出:"<<pss[p-1];
c=rand()%3+1;
cout<<"電腦出:"<<pss[c-1];
system("pause");
return 0;
}
複製代碼
作者:
邱品惟
時間:
2023-8-8 20:34
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
int player,computer,again;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
if(player<=3&&player>=1)
{
string n[]={"剪刀","石頭","布"};
cin>>player;
computer=rand()%3+1;
cout<<"你出"<<n[player-1]<<endl;
cout<<"電腦出"<<n[computer-1]<<endl;
}
else
{
cout<<"我的鞭子在哪裡"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
朱奕祈
時間:
2024-2-19 19:53
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int p,c;
string x[]={"剪刀","石頭","布"};
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>p;
c=rand()%3+1;
cout<<"你出:"<<x[p-1];
cout<<"電腦出"<<x[c-1];
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2