跳绳和跑步哪个更瘦腿:哪位大哥或大姐可以帮我编一下这道题? 我想了好久都弄不出.用C语言.非常感谢~!急用~!谢谢了~!
来源:百度文库 编辑:神马品牌网 时间:2024/10/05 10:34:36
Steps: Write a function Shuffle that shuffles an array of strings. To test the Shuffle function, write a program that
1. Declares an array with 52 elements, each of which are strings.
2. Fills the elements of that array with strings representing standard playing cards. Each card is represented by a string consisting of a rank (A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2) concatenated with a single letter representing a suit (C, D, H, S). Thus, the queen of spades is represented by the string "QS". The function IntegerToString described in Chapter 9 (page 302) will probably come in handy here.
3. Shuffles the array using the Shuffle function.
4. Deals a bridge hand by copying the first 13 cards from the deck to a separate array.
String Card[52];
String A[4]=("J","Q","K","A");
String T[4]=("C","D","H","S");//梅花,方块,红桃,黑桃
for(int j=0;j<4;j++)
for(int i=0;i<13;i++)
{
if(i<9)
Card[(i+1)*(i+1)]=T[j]+String(i+2);
else
Card[(i+1)*(i+1)]=T[j]+A[i-9];
}
Shuffer(String *Ca)//洗牌
{
int i=52;
String temp[52];
for(i=0;i<52;i++)
temp[i]="*";//初试化临时牌.
int k;
int t;
for(int j=0;j<52;j++)
{
for(;;)//这个循环判断是否选到重复的.
{
k=rand()%52;
if(temp[k]=="*")
continue;
else break;
}
switch((char)Ca[k].SubString(0,1))
{
case 'A': t=14;break;
case 'K': t=13;break;
case 'Q': t=12;break;
case 'J': t=11;break;
default: t=(int)Ca[k].SubString(0,1);
}
switch((char)Ca[k].Substring(1,1))
{
case 'C':temp[t-2]=Ca[k];break;
case 'D': temp[t-2+13]=Ca[k];break;
case 'H': temp[t-2+26]=Ca[k];break;
case 'S': temp[t-2+39]=Ca[k];break;
}//这个switch分别把各种花牌分到各个数组
// 0~12是梅花的2~A,13~25是方块的2~A,26~39是红桃
}
return temp;//返回洗好的牌
}
第4题,把40~51跟0~12对换