5
friends share accommodation. Expenses between them are shared. They have a rule
that expenses are shared equally among all friends those who are a party to
that expense. Their problem is they are poor in math. Hence they end up
fighting over expenses. Your job is to help them in splitting the expenses and
prevent in-fighting.
Write a program to help divide the expenses. The program should be generic
enough such that number of members sharing accommodation can vary. Your program
should take the following inputs and give the following output.
Assumptions:
The Person paying for a transaction is himself a party in that particular
expense
Input Format:
Line 1 contains the name
of the friends sharing the accomodation. Line 2 provides the number of
trancations(T) to be accounted. Line 3 to line T+2 will give the details of the
transactions and will contain the spender's name,the amount spent and the
friends involved in the transactions
|
Line 1 |
|
|
Line 2 |
|
|
Line 3 to Line T+2 |
|
Output Format:
|
Line 1 |
|
Sample
Inputs and Outputs:
|
SNo. |
Input |
Output |
|
1 |
|
|
|
2 |
|
|


0 Comments