G
gaulle
i'm a newbie in c. now i 'm learning it.i read a code,and compile it in
dev-c++4.9.9.0.it can
be compiled and pass.but there are some warnings.while in TC2.0,no any
warning.it's why?
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void shuffle(int[][13]);
void deal(const int[][13],const char *[],const char *[]);
main()
{
char * suit[4]={"hearts","diamonds","clubs","spades"};
char * face[13]={"ace","deuce","three","four","five","six","seven"
,"eight","nine","ten","jack","queen","king"};
int deck[4][13]={0};
srand(time(NULL));
shuffle(deck);
deal(deck,face,suit);
getch();
return 0;
}
void shuffle(int wdeck[][13])
{
int card ,row,column;
for(card=1;card<=52;card++)
{
row=rand()%4;
column=rand()%13;
while(wdeck[row][column]!=0)
{
row=rand()%4;
column=rand()%13;
}
wdeck[row][column]=card;
}
}
void deal(const int wdeck[][13],
const char *wface[],
const char *wsuit[])
{
int card,row,column;
for(card=1;card<=52;card++)
for(row=0;row<=3;row++)
for(column=0;column<=12;column++)
if(wdeck[row][column]==card)
printf("%5s of
%8s%c",wface[column],wsuit[row],card%2==0?'\n':'\t');
}
dev-c++4.9.9.0.it can
be compiled and pass.but there are some warnings.while in TC2.0,no any
warning.it's why?
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void shuffle(int[][13]);
void deal(const int[][13],const char *[],const char *[]);
main()
{
char * suit[4]={"hearts","diamonds","clubs","spades"};
char * face[13]={"ace","deuce","three","four","five","six","seven"
,"eight","nine","ten","jack","queen","king"};
int deck[4][13]={0};
srand(time(NULL));
shuffle(deck);
deal(deck,face,suit);
getch();
return 0;
}
void shuffle(int wdeck[][13])
{
int card ,row,column;
for(card=1;card<=52;card++)
{
row=rand()%4;
column=rand()%13;
while(wdeck[row][column]!=0)
{
row=rand()%4;
column=rand()%13;
}
wdeck[row][column]=card;
}
}
void deal(const int wdeck[][13],
const char *wface[],
const char *wsuit[])
{
int card,row,column;
for(card=1;card<=52;card++)
for(row=0;row<=3;row++)
for(column=0;column<=12;column++)
if(wdeck[row][column]==card)
printf("%5s of
%8s%c",wface[column],wsuit[row],card%2==0?'\n':'\t');
}