#include <_stdio.h_>
int main() {
printf("\nHello World\n");
int tests[ ] = { 71, 83, 67, 49, 59 };
int val[5] = { 0 };
for ( int i=0; i<5; i++ ) {
printf("tests[%d]=%d \n", i, tests[i] );
}
for ( int i=0; i<5; i++ ) printf("val[%d]=%d \n", i, val[i] );
return 0;
}
#include <_stdio.h_>
#include <_stdlib.h_>
#include <_time.h_>
int main() {
int done[53] = {0}, card[53]={0}, busy = 1;
int i = 0; //i=發到第幾張牌
srand( clock() );
while ( 1 ) {
if ( ++i > 52 ) break;
busy = 1;
while ( busy ) {
int n = rand() % 52 + 1; //(0~51)+1=1~52
if ( done[n] == 0 ) {
done[n] = 1; //表示這張牌已被使用
card[i] = n; //發出去這張牌
busy = 0;
}
}
}
for( i=1; i<= 52; i++ ) {
//if ( card[i] < 10 ) printf( " " );
//printf( "d,", card[i]);
printf( "-,", card[i]);
//printf( "%d,", card[i]);
if ( i == 0) printf("\n"); //10張就斷行
}
return 0;
}
int main() {
int k = 0;
printf("\n請輸入一個小於15的數值:");
scanf("%d", &k);
if ( k < 15 ) {
int tests[15] = { 71, 83, 67, 49, 59 };
int val[15] = { 0 };
for ( int i=0; i
printf("tests[%d]=%d \n", i, tests[i] );
}
for ( int i=0; i
printf("val[%d]=%d \n", i, val[i] );
}
} else {
printf("輸入數值太大 %d \n", k );
}
return 0;
}