[2012] array questions

Source: Internet
Author: User

1. Talent Show scoring, which can be divided into expert judges and public judges. The score [] array stores the scores of each judge. The judge_type [] stores the judges' categories corresponding to the score [] array, judge_type [I] = 1, indicating the expert judges, judge_type [I] = 2, indicating the public judges, and N indicating the total number of judges. The scoring rules are as follows: The scores of expert judges and public judges are divided into one average score (average score), and then the total score = the average score of expert judges * 0.6 + public judges * 0.4, the total score is rounded up. If no public judges are available, the total score is equal to the average score of the panel judges, and the total score is rounded up. The function returns the score of the contestant.

 

Int cal_score (INT score [], int judge_type [], int N) {int exsumscore = 0, pesumscore = 0; int exnum = 0, penum = 0; int res = 0; for (unsigned I = 0; I <n; I ++) {If (judge_type [I] = 1) {exsumscore + = score [I]; exnum ++ ;} else {pesumscore + = score [I]; penum ++ ;}} if (penum = 0) RES = exsumscore/exnum; else res = int (exsumscore/exnum) * 0.6 + (pesumscore/penum) * 0.4); Return res ;}

 

 

 

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.