POJ C Programming Advanced Programming Question # #: Invoice Statistics

Source: Internet
Author: User

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB

Description

There is a small reimbursement system, it has the following functions:

(1) Statistics of the total amount of invoices submitted by each person

(2) Statistics of total amount of each type of invoice

simplify the system to the following: Assume that the invoice category has a, B, C three, a total of three people, the IDs are 1, 2, 3.  

input

The system input contains three rows, the first number of each line is the Person ID (integer, 1 or 2, or 3), the second number is the total invoice number (no more than 100), followed by multiple invoice categories (character, a or B, or C) and the corresponding invoice amount (single-progress float, not more than 1000.0).

Output

The output contains six rows, the first three behaviors per person (by the size of the ID from small to large output) the total amount of the invoice (reserved two decimal places), the last three behaviors of each type of invoice total money (reserved two decimal places).  

Sample Input
1 5 A 1.0 a 2.0 C 1.0 b 1.0 c 3 B 1 C 2 C 4 B 1 a 1 C 1 a 1
Sample Output
1 6.002 4.003 4.00A 5.00B 3.00C 6.00
1#include <iostream>2#include <stdio.h>3 using namespacestd;4 5 intMain ()6 {7     floatsum[6];8     9      for(inti =0; I <3; i++){Ten         intA; OneCIN >>A; A         intN; -CIN >>N; -          for(intj =0; J < n;j++){ the             Charb; -CIN >>b; -             floatC; -CIN >>C; +             if(b = ='A') { -sum[a-1] +=C; +sum[3] +=C; A             } at             Else if(b = ='B') { -Sum[a-1] +=C; -sum[4] +=C; -             }  -             Else if(b = ='C') { -Sum[a-1] +=C; insum[5] +=C; -             }     to         } +     } -printf"1%.2f\n", sum[0]); theprintf"2%.2f\n", sum[1]); *printf"3%.2f\n", sum[2]); $printf"A%.2f\n", sum[3]);Panax Notoginsengprintf"B%.2f\n", sum[4]); -printf"C%.2f\n", sum[5]); the     return 0; +}

POJ C Programming Advanced Programming Question # #: Invoice Statistics

Related Article

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.