//************************************** **************************************** * ** // 6th questions // counts the number of people who celebrate their birthdays each month, for 120 people, the calendar month of their birthdays is randomly generated. //************************************** **************************************** * ** # Include <stdio. h> # include <stdlib. h> void main () {int birth [120]; int month [12] = {0}; int COUNT = 1; printf ("Employee's birthday list: \ n "); For (INT I = 0; I <120; I ++) {birth [I] = rand () % 12 + 1; for (Int J = 0; j <12; j ++) {If (Birth [I] = J + 1) {month [J] ++ ;}} printf ("% 5d", Birth [I]); If (count % 10 = 0) {printf ("\ n") ;}count ++ ;} printf ("\ n birthday statistics: \ n"); For (int K = 0; k <12; k ++) {printf ("% 2D months :", k + 1); printf ("% 3d \ n", month [k]);}
Employee birthday list:
6 12 11 5 6 5 7 7 11 9
6 6 2 4 2 12 8 3 4 1
4 1 3 10 5 11 10 9 3 12
12 7 12 7 10 5 12 8 8 7
12 4 3 10 10 9 10 8 6 5
12 9 11 10 10 8 12 10 2 11
5 12 3 7 1 11 5 3 5
3 10 3 10 11 3 7 10 9
10 12 1 11 1 9 11 9 12 5
1 4 3 8 6 11 3 7 10 6
10 12 8 7 1 7 10 3 6 7
6 6 9 5 7 10 6 10 10 1
Birthday statistics:
December: 8
December: 3
December: 12
December: 5
December: 11
December: 11
December: 12
December: 7
December: 8
December: 20
December: 10
December: 13
Press any key to continue...