1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#include <iostream>
#include <cmath>
using namespace std;
#include <cstdlib>
#include <ctime>
using namespace std;
void coin_changer (int,int &, int &, int &, int &, int &); //function prototype
int main()
{
int files;
int hund;
int fift;
int twent;
int tens;
int five;
unsigned seed=time(0);
srand(seed);
files=1+rand()%1000;
coin_changer(files,hund,fift,twent,tens,five);
cout<<"enter the amount of money you have: "<< files <<"files"<<endl;
cout<<" \n";
coin_changer(files,hund, fift, twent, tens, five);
cout<< "the amount contains: \n";
cout<< hund <<" coins of 100 files.\n";
cout<< fift <<" coins of 50 files.\n";
cout<< twent <<" coins of 20 files.\n";
cout<< tens <<" coins of 10 files.\n";
cout<< five <<" coins of 5 files.\n";
cout<< endl;
return 0;
}
void coin_changer(int files, int &hund, int &fift, int &twent, int &tens, int &five )
{
hund=files/100;
files=files%100;
fift=files/50;
files=files%50;
twent=files/20;
files=files%20;
tens=files/10;
files=files%10;
five=files/5;
}
/*
enter the amount of money you have: 135files
the amount contains:
1 coins of 100 files.
0 coins of 50 files.
1 coins of 20 files.
1 coins of 10 files.
1 coins of 5 files.
Press any key to continue
*/
/*
enter the amount of money you have: 288files
the amount contains:
2 coins of 100 files.
1 coins of 50 files.
1 coins of 20 files.
1 coins of 10 files.
1 coins of 5 files.
Press any key to continue
*/
|