標題:
猜拳遊戲 (一)
[打印本頁]
作者:
陳品肇
時間:
2022-2-26 10:36
標題:
猜拳遊戲 (一)
運用產生隨機亂數的技巧, 設計一個猜拳遊戲,
使用者可以選擇出剪刀石頭或布, 電腦隨機出拳.
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
[attach]12823[/attach]
作者:
黃奕澄
時間:
2022-2-26 11:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林紘憲
時間:
2022-2-26 11:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
曾善勤
時間:
2022-2-26 11:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
鍾易澄
時間:
2022-2-26 11:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布: ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許宸瑀
時間:
2022-2-26 11:17
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許馹東
時間:
2022-2-26 11:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
srand(time(NULL));
int x,z;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>x;
z=rand()%3+1;
cout<<"你出";
if(x==1)
cout<<"剪刀!"<<endl;
else if(x==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(z==1)
cout<<"剪刀!"<<endl;
else if(z==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
孫子傑
時間:
2022-2-26 11:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
}
複製代碼
作者:
郭博鈞
時間:
2022-2-26 11:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player, computer;
cout<<"請出拳! (1)剪刀 (2)石頭 (3)布"<<endl;
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀"<<endl;
else if(player==2)
cout<<"石頭"<<endl;
else
cout<<"布"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-2-26 11:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
{
cout<<"剪刀!"<<endl;
}
else if(player==2)
{
cout<<"石頭!"<<endl;
}
else
{
cout<<"布!"<<endl;
}
cout<<"電腦出";
if(computer==1)
{
cout<<"剪刀!"<<endl;
}
else if(computer==2)
{
cout<<"石頭!"<<endl;
}
else
{
cout<<"布!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
高鋐鈞
時間:
2022-2-26 11:32
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int x,y;
cout<<"請出拳 (1)剪刀(2)石頭(3)布";
cin>>x;
y=rand()%3+1;
cout<<"你出";
if(x==1)
{
cout<< "剪刀"<<endl;
}else if(x==2)
{
cout<< "石頭"<<endl;
}else
{
cout<< "布"<<endl;
}
cout<<"電腦出";
if(y==1)
{
cout<< "剪刀"<<endl;
}else if(x==2)
{
cout<< "石頭"<<endl;
}else
{
cout<< "布"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
徐譽豈
時間:
2022-2-26 11:35
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳!(1)剪刀(2)石頭(3)布";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林鴻慶
時間:
2022-3-5 09:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player==1)
cout<<"剪刀!"<<endl;
else if(player==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
cout<<"電腦出";
if(computer==1)
cout<<"剪刀!"<<endl;
else if(computer==2)
cout<<"石頭!"<<endl;
else
cout<<"布!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
柳侑辰
時間:
2022-3-5 09:23
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
if(player == 1)
{
cout<<"剪刀!"<<endl;
}else if(player == 2)
{
cout<<"石頭!"<<endl;
}else
{
cout<<"布!"<<endl;
}
cout<<"電腦出";
if(computer == 1)
{
cout<<"剪刀!"<<endl;
}else if(computer == 2)
{
cout<<"石頭!"<<endl;
}else
{
cout<<"布!"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2