2018年1月12日 星期五

[MM47-易] Counting Bus Fare(C++)

[MM47-易] Counting Bus Fare

Problem Description
Write a program counting bus fare for a group of passengers, which includes adults, children, and seniors. The number and fare for each type of passengers is entered by the user. Your program will calculate the total bus fare for this group of passengers.
Input File Format
The input has three rows, first row shows 2 integers representing the number and the fare of adults; second row shows 2 integers representing the number and the fare of children; and third row shows 2 integers representing the number and the fare of seniors.
Output Format
Output the bus fare according to the input
Example

Sample Input:Sample Output:
2 10
3 5
4 2
43
  1. #include <iostream>  
  2. using namespace std;  
  3.   
  4. int main() {  
  5.     // [MM47-易]計數巴士票價  
  6.     int aNUM, aMON, cNUM, cMON, oNUM, oMON;  
  7.     while(cin >> aNUM >> aMON >> cNUM >> cMON >> oNUM >> oMON)  
  8.     {  
  9.         int result = aNUM*aMON+cNUM*cMON+oNUM*oMON;  
  10.         cout << result << endl;  
  11.     }  
  12.     return 0;  
  13. }  

沒有留言:

張貼留言