妖精尾巴bg原创女主:一道C语言的题目 送分 请人给个完整的代码

来源:百度文库 编辑:高校问答 时间:2024/04/30 01:33:13
具体题目是这样的...

Contents:
This assignment gives students the opportunity to work with arrays and sorting.Programs that simulate card games usually have to simulate the operation of shuffling the deck. Like sorting, shuffling is a process that involves rearranging the elements of an array. Algorithmically, the only difference between sorting and shuffling is how you select elements. When you sort an array using selection sort, you choose the smallest element in the rest of the array on each cycle of the loop. When you shuffle an array, you choose a random element. At last, you should sort the 13 cards in descending order by suit.
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.
5. Sorts the 13 cards in the hand so that the cards are in descending order by suit. When the hand is sorted, all the spades come first, followed by the hearts, the diamonds, and finally the clubs. Within each suit, the cards should be listed in the order given in step 2: first the ace, then the king, then the queen, and so on down to the two. Note that this step requires an operation that is pretty much the same as the Sort function in the text. The only differences are that (1) the array elements are strings and (2) the comparison operation is slightly more complicated. In all other ways, your program should follow exactly the same structure.
6. Displays the 13 cards in the hand on a single line.
The following is a sample run of the program:
Hand: AS 6S AH 10H 7H 4H KD 8D 5D 4D 3D 2D AC
大概是这样的,这个程序是排序,也就是将52张扑克排随机抽取13张扑克排,按花色不同从大到小排列,其中H表示红心,D表示方块,C为梅花,S为黑桃,
首先要初始化一个数组里面包含52个元素,也就是52张牌了,
第二步就是洗牌,就是将52张牌的顺序打乱
第三步呢,是抓牌了,随机出现13张牌,注意思路是4个人,一人一张的给,只要求得到一组就好了
第四步是将上面的13张牌用另外的数组放着
第五步是排序,具体是S.H.D.C.其中牌面的大小是按A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2
第六步是把这13张牌显示在屏幕上.
下面的这个就是所要求的格式了
AS 6S AH 10H 7H 4H KD 8D 5D 4D 3D 2D AC

如果有人能给出答案 请发送到我的电子邮箱 kg01@163.com 或者 联系我的QQ 114089522

/***********************************************
1,把牌分给了四个人,最后把四个人得牌都重新排了顺序
2,由于用了函数rand()是一个伪随机数生成函数,是根据公式生成得,所以每次生成的随机数序列是一样的(至少我用的TC2.0是这样得)。
3,要改变每次的结果,可以通过改变洗牌函数void xie(pai *p)中的循环控制次数K实现(K的变化要大,效果才明显)
4,不明白函数什么意思,你就看函数得汉语拼音,自己理解。
**********************************************/

这么复杂还叫送分啊,去软件技术基础这些书上应该能找到。去图书馆也能找到很多这样的

太麻烦了 做起来太慢 真懒得写了