theo830

money

Apr 7th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<list>
  4. #include<algorithm>
  5. #include <iomanip>
  6. using namespace std;
  7. int main(){
  8. int a;
  9. cin>>a;
  10. int b;
  11. string c[a];
  12. int s[a];
  13. int x;
  14. float t;
  15. string w;
  16. int k=0;
  17. int j=0;
  18. for(int i=0;i<a;i++){
  19. c[i] = "0";
  20. s[i] = 0;
  21. }
  22. for(int i=0;i<a;i++){
  23. cin>>b;
  24. if(b == 1){
  25. int r = 0;
  26. cin>>w>>x;
  27. for(int j=0;j<a;j++){
  28. if(w == c[j] && r != 1){
  29. r = 1;
  30. s[j] = s[j] + x;
  31. //cout<<s[j]<<endl;
  32. }
  33. else if(c[j] == "0" && r != 1){
  34. r = 1;
  35. s[j] = x;
  36. c[j] = w;
  37. //cout<<s[j]<<endl;
  38. }
  39. }
  40. }
  41. else if(b == 2){
  42. cin>>w;
  43. for(int j=0;j<a;j++){
  44. if(w == c[j]){
  45. s[j] = 0;
  46. //cout<<s[j]<<endl;
  47. }
  48. }
  49. }
  50. else{
  51. int o=0;
  52. cin>>w;
  53. for(int j=0;j<a;j++){
  54. if(w == c[j] && o != 1){
  55. o=1;
  56. cout<<s[j]<<endl;
  57. }
  58. }
  59. if(o == 0){
  60. cout<<0<<endl;
  61. }
  62. }
  63. }
  64. t = 0;
  65. for(int i=0;i<a;i++){
  66. if(s[i] != 0){
  67. t = t + s[i];
  68. k++;
  69. }
  70. }
  71. t = t / k;
  72. cout<<setprecision(2)<<fixed<<t;
  73. return 0;
  74. }
Add Comment
Please, Sign In to add comment