printf(\ }
getchar(); return 0; }
//*********fun.h***********// #include
int rand0(void); void sort(int *str);
//************fun.c***************// #include
int rand0(void) {
intnum;
num=rand()+1; returnnum; }
void sort(int *str) {
inti, j, temp;
for (i=0; i<100; i++) {
for (j=0; j<100-i-1; j++) {
if (str[j] temp=str[j]; str[j]=str[j+1]; str[j+1]=temp; } } } } 6. #include int rand0(); int main(void) { intStr[10]={0}; int count; int value; for(count=0; count<1000; count++) { value=rand0(); Str[value-1]++; } for (count=0; count<10; count++) { printf(\, Str[count]); } getchar(); return 0; } int rand0() { intnum; num=rand()+1; returnnum; } 7. //****************main.c*************// #include int main(void) { int dice, roll; int sides, sets; int status; inti; srand( (unsignedint) time(0) ); printf(\); while(scanf(\, &sets)==1 && sets>0) { if (sets=='q') { break; } printf(\); if(scanf(\, &sides)==1 && sides>0) { printf(\); if( (status =scanf(\, &dice))!=1) { if (status==EOF) { break; } else { printf(\); printf(\); while(getchar()!='\\n') { continue; } printf(\); continue; } } printf(\, sets, dice, sides); for (i=0; i roll=roll_n_dice(dice, sides); printf(\, roll ); } putchar('\\n'); printf(\); } } printf(\, roll_count); printf(\); getchar(); return 0; } //**************diceroll.h**************// externintroll_count; introll_n_dice(int dice, int sides); //*************diceroll.c**************// #include\ #include introll_count=0; staticintrollem(intsides) { int roll; roll=rand()%sides+1; roll_count++; return roll; } introll_n_dice(intdice, intsides) { int d; int total=0; if(sides<2) { printf(\); return -2; } if (dice<1) { } printf(\); return -1; } for (d=0; d total +=rollem(sides); } return total; 8. #include int *make_array(intelem, intval); voidshow_array(constintar[], int n); int main(void) { int *pa; int size; int value; printf(\); while(scanf(\, &size)==1 && size>0) { printf(\); scanf(\, &value); pa=make_array(size, value); if (pa) { show_array(pa, size); free(pa); } printf(\); } printf(\); getchar(); return 0;