Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. /*
  2. ID: antrian2
  3. TASK: gift1
  4. LANG: C++
  5. */
  6. #include <iostream>
  7. #include <fstream>
  8. #include <string>
  9.  
  10. using namespace std;
  11.  
  12. struct turtles
  13. {
  14. string name;
  15. int pocket;
  16.  
  17. };
  18.  
  19.  
  20. int main()
  21. {
  22. ifstream fin("gift1.in");
  23. ofstream fout("gift1.out");
  24. int n;
  25. fin>>n;
  26. turtles tortelinias[n];
  27. string tmps,tmps2;
  28. int tmpmon,tmpreic;
  29. for(int i=0; i<n;i++)
  30. {
  31. fin>>tortelinias[i].name;
  32. tortelinias[i].pocket=0;
  33. }
  34. for(int kl=0;kl<n;kl++)
  35. {
  36. fin>>tmps>>tmpmon>>tmpreic;
  37. for(int i=0; i<n;i++)
  38. {
  39. if(tortelinias[i].name==tmps)
  40. {
  41. tortelinias[i].pocket=tortelinias[i].pocket+(tmpmon%tmpreic)-tmpmon;
  42. if(tmpreic!=0)
  43. {
  44. tmpmon=tmpmon/tmpreic;
  45. }
  46.  
  47. for(int j=0; j<tmpreic;j++)
  48. {
  49. fin>>tmps2;
  50. for(int k=0;k<n;k++)
  51. {
  52. if(tortelinias[k].name==tmps2)
  53. {
  54. tortelinias[k].pocket=tortelinias[k].pocket+tmpmon;
  55. break;
  56. }
  57. }
  58. }
  59.  
  60. }
  61. }
  62. }
  63. for(int i=0; i<n;i++)
  64. {
  65. fout<<tortelinias[i].name<<" "<<tortelinias[i].pocket<<endl;
  66. }
  67. fin.close();
  68. fout.close();
  69. return 0;
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement