[C language Ta] counts the number of people who celebrate their birthdays each month. 120 of them are randomly generated for their birthdays.

Source: Internet
Author: User
//************************************** **************************************** * ** // 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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.