C/C++の宿題を片付けます 116代目at TECH
C/C++の宿題を片付けます 116代目 - 暇つぶし2ch172:デフォルトの名無しさん
08/10/09 00:37:56
>>171
こんなんでおk?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void swap(int*a,int*b){int c = *a;*a=*b;*b = c;}
int main(void)
{
&nbsp; &nbsp; int i,n;
&nbsp; &nbsp; char *card[]={"Club","Diamond","Heaart","Spade"};
&nbsp; &nbsp; char *numb[]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
&nbsp; &nbsp; int cards[52];
&nbsp; &nbsp; for(i=0;i<52;++i)
&nbsp; &nbsp; &nbsp; &nbsp; cards[i] = i;
&nbsp; &nbsp; srand(time(NULL));
&nbsp; &nbsp; //カードをシャッフルする
&nbsp; &nbsp; for(i=0;i<52;++i)
&nbsp; &nbsp; &nbsp; &nbsp; swap(cards+i,cards+rand()%(52-i)+i);
&nbsp; &nbsp; for(i=0;i<52;++i)
&nbsp; &nbsp; &nbsp; &nbsp; printf("%cさん %s%s\n","ABCDE"[i%5],card[cards[i]/13],numb[cards[i]%13]);
&nbsp; &nbsp; return 0;
}



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch