Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define NUM 10
- void result(int count, int num);
- int count1=0, count2=0, count3=0, count4=0, count5=0, count6=0, count7=0, count8=0, count9=0, count10=0;
- int count=0;
- int main(void){
- int rando, i, x;
- time_t t;
- srand((unsigned) time(&t));
- for(i=0; i<10; i++){
- extern int count1, count2, count3, count4, count5, count6, count7, count8, count9, count10;
- for(x=0; x<1000;x++){
- rando=rand()%10+1;
- switch (rando){
- case 1:count1++;
- break;
- case 2:count2++;
- break;
- case 3:count3++;
- break;
- case 4:count4++;
- break;
- case 5:count5++;
- break;
- case 6:count6++;
- break;
- case 7:count7++;
- break;
- case 8:count8+=1;
- break;
- case 9:count9++;
- break;
- case 10:count10++;
- break;
- }
- }
- result(count1, 1);
- result(count2, 2);
- result(count3, 3);
- result(count4, 4);
- result(count5, 5);
- result(count6, 6);
- result(count7, 7);
- result(count8, 8);
- result(count9, 9);
- result(count10, 10);
- count1=0;
- count2=0;
- count3=0;
- count4=0;
- count5=0;
- count6=0;
- count7=0;
- count8=0;
- count9=0;
- count10=0;
- printf("\n");
- printf("\n");
- }
- return 0;
- }
- void result(int count, int num){
- printf("You have %d %ds.\n", count, num);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement