Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: antrian2
- TASK: gift1
- LANG: C++
- */
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct turtles
- {
- string name;
- int pocket;
- };
- int main()
- {
- ifstream fin("gift1.in");
- ofstream fout("gift1.out");
- int n;
- fin>>n;
- turtles tortelinias[n];
- string tmps,tmps2;
- int tmpmon,tmpreic;
- for(int i=0; i<n;i++)
- {
- fin>>tortelinias[i].name;
- tortelinias[i].pocket=0;
- }
- for(int kl=0;kl<n;kl++)
- {
- fin>>tmps>>tmpmon>>tmpreic;
- for(int i=0; i<n;i++)
- {
- if(tortelinias[i].name==tmps)
- {
- tortelinias[i].pocket=tortelinias[i].pocket+(tmpmon%tmpreic)-tmpmon;
- if(tmpreic!=0)
- {
- tmpmon=tmpmon/tmpreic;
- }
- for(int j=0; j<tmpreic;j++)
- {
- fin>>tmps2;
- for(int k=0;k<n;k++)
- {
- if(tortelinias[k].name==tmps2)
- {
- tortelinias[k].pocket=tortelinias[k].pocket+tmpmon;
- break;
- }
- }
- }
- }
- }
- }
- for(int i=0; i<n;i++)
- {
- fout<<tortelinias[i].name<<" "<<tortelinias[i].pocket<<endl;
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement