標題:
任抽一張撲克牌
[打印本頁]
作者:
陳品肇
時間:
2019-4-19 22:15
標題:
任抽一張撲克牌
設計一小程式, 可以隨機地顯示整組52張撲克牌中的任一張牌號.
[attach]6310[/attach]
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=rand()%4+3;
int b=rand()%13+1;
cout<<"您抽到的牌是: "<<char(a);
if(b==1)
cout<<"A";
else if(b==11)
cout<<"J";
else if(b==12)
cout<<"Q";
else if(b==13)
cout<<"K";
else
cout<<b;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2019-4-20 16:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=rand()%4+3;
int b=rand()%13+1;
cout<<"您抽到的牌是: "<<char(a);
if(b==1)
cout<<"A";
else if(b==11)
cout<<"J";
else if(b==12)
cout<<"Q";
else if(b==13)
cout<<"K";
else
cout<<b;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2019-4-20 16:23
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=rand()%4+3;
int b=rand()%13+1;
cout<<"您抽到的牌是: "<<char(a);
if(b==1)
{
cout<<"A";
}
else if(b==11)
{
cout<<"J";
}
else if(b==12)
{
cout<<"Q";
}
else if(b==13)
{
cout<<"K";
}
else
{
cout<<b;
}
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
戴偉宸
時間:
2019-4-20 16:26
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=rand()%4+3;
int b=rand()%13+1;
cout<<"您抽到的牌是: "<<char(a);
if(b==1)
cout<<"A";
else if(b==11)
cout<<"J";
else if(b==12)
cout<<"Q";
else if(b==13)
cout<<"K";
else
cout<<b;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
蔡季庭
時間:
2019-4-20 16:28
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int gg=rand()%4+3;
int ggking=rand()%13+1;
cout<<"您抽到的牌是: "<<char(gg);
if(ggking==1)
cout<<"A";
else if(ggking==11)
cout<<"J";
else if(ggking=12)
cout<<"Q";
else if(ggking==13)
cout<<"K";
else
cout<<ggking;
cout<<endl;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
戴安利
時間:
2019-4-20 16:30
本帖最後由 戴安利 於 2019-4-20 16:32 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=rand()%4+3;
int b=rand()%13+1;
cout<<"您抽的牌是: "<<char(a);
if (b==1)
cout<<" A ";
else if(b==11)
cout<<" J ";
else if(b==12)
cout<<" Q ";
else if(b==13)
cout<<" K ";
else
cout<<" "<<b<<" ";
system("pause");
goto re;
return 0;
}
複製代碼
作者:
戴唯陞
時間:
2019-4-20 16:32
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=rand()%4+3;
int b=rand()%13+1;
cout<<"你抽到的牌是"<<char(a);
if(b==1)
cout<<"A"<<endl;
else if(b==11)
cout<<"J"<<endl;
else if(b==12)
cout<<"Q"<<endl;
else if(b==13)
cout<<"K"<<endl;
else
cout<<b;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
陳柏霖
時間:
2019-5-2 17:04
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a ,b;
string n[]={"1","2","3","4","5","6","7","8","9","10","J","Q","K"};
a=rand()%4+3;
b=rand()%13;
cout<<"你抽到的牌是:"<<char(a)<<n[b]<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2