Advertisement
Guest User

Untitled

a guest
May 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <algorithm>
  5. #include <fstream>
  6. #include <set>
  7. #include <string>
  8. #include <cmath>
  9. #include <list>
  10. #include <deque>
  11. #include <iterator>
  12. #include <time.h>
  13. #include <cmath>
  14. #include <iomanip>
  15.  
  16. using namespace std;
  17. using ll = long long;
  18.  
  19. struct comp
  20. {
  21. int price;
  22. string name;
  23. string country;
  24. string date;
  25. };
  26.  
  27. void input(comp *a)
  28. {
  29. cin >> a->name;
  30. cin >> a->country;
  31. cin >> a->price;
  32. cin >> a->date;
  33. }
  34. int middle(comp **a, int sum,int n)
  35. {
  36. for (int i = 0; i < n; i++)
  37. {
  38. sum += a[i]->price;
  39. }
  40. return sum;
  41. }
  42.  
  43. void highest(comp **a, int n)
  44. {
  45. string str = a[0]->country;
  46. string ans=a[0]->name;
  47. int high=a[0]->price;
  48. bool check = false;
  49. for (int i = 0; i < n; i++)
  50. {
  51. while (i < n&&str == a[i]->country)
  52. {
  53. check = true;
  54. if (high < a[i]->price)
  55. {
  56. ans = a[i]->name;
  57. high = a[i]->price;
  58. }
  59. i++;
  60. }
  61. if (check)
  62. {
  63. check = false;
  64. i--;
  65. }
  66. }
  67. }
  68.  
  69. int main() {
  70. ifstream cin("input.txt");
  71. int n,sum=0;
  72. scanf("%d", &n);
  73. comp** a = (comp**)malloc((n + 1)*sizeof(comp*));
  74. for (int i = 0; i < n; i++)
  75. {
  76. a[i] = (comp*)malloc(sizeof(comp));
  77. input(a[i]);
  78. }
  79. sort(a->country.begin(), a->country.end());
  80. highest(a,n);
  81. system("pause");
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement