# Notes and coins

## Problem:-

You are given M number of coins and P number of notes.
Write a program to separate the two forms of money without creating two separate classes for notes and coins.
(The order of the output should be the same as that of the input).
Input format

• First line : N
• Next N lines : Space-separated string S and an integer
$val$

(where S is either a Coin or a Note and

$val$

denotes the denomination of a coin or a note)

Output format
Print the string Coins : followed by M lines, each of which contains an integer denoting the denominations of the coins.
Print the string Notes : followed by P lines, each of which contains an integer denoting the denominations of the notes.
Constraints

$1\le N\le {10}^{2}$

$1\le Val\le {10}^{2}$

Description of Classes:
You need to design 3 classes:

• Bag
• Coin
• Note

Note and Coin Class
Both the classes have common attributes as well as common methods.
Attributes:
Val: refers to the denomination of the coin or note
Methods:
setvalue(int val): Set the denomination of the coin to the value which is passed as a parameter.
Bag Class
This should be a generic class.
Methods
Display(): Display the denomination of the coin or note.

SAMPLE INPUT

`7Note 83Coin 19Coin 85Note 8Note 30Coin 56Coin 53`
SAMPLE OUTPUT

`Coins :19855653Notes :83830`
Explanation

The denomination on Notes and Coins are displayed in the required order.
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

## solution:-

#include<stdio.h>
void main()
{
int n,val,i,k=0,a,c,l=0,x;
char s;
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
scanf(“%s”,s);
scanf(“%d”,&val);
x=s;
if(x==78)
{ a[k]=val;
k++;
}
if(x==67)
{
c[l]=val;
l++;
}
}
printf(“Coins :n”);
for(i=0;i<l;i++)
{
printf(“%dn”,c[i]);
}
printf(“Notes :n”);
for(i=0;i<k;i++)
{
printf(“%dn”,a[i]);
}
}