看板NCCU_KS1
标 题张意正你不要出老千呴
发信站荒漠传奇 (Thu Mar 10 17:10:06 2005)
转信站ptt!Group.NCTU!grouppost!Group.NCTU!desert
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifndef _Poker_H
void MappingPoker(
int poker);
#endif
void main(){
int A[
52],i,temp,a,b;
for(i=
0;i<=
51;i++){
//赋予A阵列1到52
A[i]=i+
1;
}
srand((
unsigned) time(
NULL));
//找随机乱数表
for(i=
0;i<=
1000;i++){
//进行A阵列中随意调换
a=rand()%
52;
b=rand()%
52;
temp=A[a];
A[a]=A[b];
A[b]=temp;
}
do{
printf(
"\ninput the number which you want to pick:");
scanf(
"%d",&temp);
}
while(temp>
52||temp<
1);
for(i=
0;i<temp;i++){
MappingPoker(A[i]);
}
printf(
"\n");
}
void MappingPoker(
int poker){
//数字对应到扑克牌
if(poker/
13==
0)
//黑桃
printf(
"S ");
if(poker/
13==
1)
//红心
printf(
"H ");
if(poker/
13==
2)
//砖块
printf(
"D ");
if(poker/
13>=
3)
//梅花
printf(
"C ");
if(poker%
13<=
10)
if(poker%
13==
1)
printf(
"A\t");
//A士
else
printf(
"%d\t",poker%
13);
else if(poker%
13==
11)
//Jack
printf(
"J\t");
else if(poker%
13==
12)
//Queen
printf(
"Q\t");
else if(poker%
13==
13)
//King
printf(
"K\t");
}
----
花二十分钟写的 XD
--
⊕╮荒漠传奇.幻想的起点╭╮╫ ● ╭→ bbs.math.nccu.edu.tw
since May 1999 ←⊕
╰ desert.twbbs.org ─╯╰╨─→╯↘→ opower from ( 140.119.191.217 )