* 1012. digital classification

Source: Internet
Author: User
1/* 2 * Main. C 3*1012. digital classification 4 * created on: August 30, 2014 5 * Author: boomkeeper 6 ********* part through ******* 7 */8 9 # include <stdio. h> 10 # include <math. h> 11 12 Void A1 (INT in, int * sum) {13 14 if (in % 5 = 0 & in % 2 = 0) 15 (* sum) + = In; 16} 17 18 void A2 (INT in, int * sum, int * count) {19 20 if (in % 5 = 1) {21 (* sum) + = POW (-1, * count) * in; 22 (* count) ++; 23} 24} 25 26 void A3 (INT in, int * count) {27 28 If (in % 5 = 2) 29 (* count) ++; 30} 31 32 void A4 (INT in, int * sum, int * count) {33 34 if (in % 5 = 3) {35 (* count) ++; 36 (* sum) + = in; 37} 38} 39 40 void A5 (INT in, int * max) {41 42 if (in % 5 = 4) 43 If (* max <in) 44 * max = In; 45} 46 47 void output (int * sum1, int * sum2, int * count3, int * sum4, int * count4, int * max) {48 if (* sum1 = 0) 49 printf ("N"); 50 else51 printf ("% d", * sum1 ); 52 53/* the result of the staggered sum may be 0, and the output N or 0 is to be determined */54 if (* sum2 = 0) 55 printf ("N "); 56 else57 printf ("% d", * sum2); 58 59 If (* count3 = 0) 60 printf ("N"); 61 else62 printf ("% d ", * count3); 63 64 if (* count4 = 0) 65 printf ("N"); 66 else67 printf ("%. 1f ", (float) (* sum4)/(* count4); 68 69 If (* max = 0) 70 printf (" N "); 71 else72 printf ("% d \ n", * max); 73} 74 75 int main (void) {76 77 int in; 78 int N; // N79 int I; 80 int sum1 = 0, sum2 = 0, sum4 = 0; // sum81 int count2 = 0, count3 = 0 in A1, A2, and A4, count4 = 0; // count 82 int max = 0 in A2, A3, and A4; // The maximum number of records in A5 is 83 84 scanf ("% d", & N ); 85 86 for (I = 0; I <n; I ++) {87 scanf ("% d", & in); 88 A1 (in, & sum1 ); 89 A2 (in, & sum2, & count2); 90 A3 (in, & count3); 91 A4 (in, & sum4, & count4); 92 A5 (in, & MAX); 93} 94 95 output (& sum1, & sum2, & count3, & sum4, & count4, & MAX); 96 97 return 0; 98}

 

This question took a long time. I didn't submit it at the time. I couldn't think of the idea at the time. I 'd like to release it first, or I will forget it later.

 

Question link:

Http://pat.zju.edu.cn/contests/pat-b-practise/1012

 

 

.

* 1012. digital classification

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.