Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct TAuto {
  6. string make = "";
  7. int year = 0;
  8. float volume = 0, consumption = 0;
  9. };
  10.  
  11. int main() {
  12.  
  13. int size;
  14. cout << "Enter the size of the list: ";
  15. cin >> size;
  16.  
  17. TAuto* list = new TAuto[size];
  18.  
  19. for (int i = 0; i < size; ++i) {
  20. cout << i + 1 << "\nMake: ";
  21. cin >> (list + i)->make;
  22. cout << "Year: ";
  23. cin >> (list + i)->year;
  24. cout << "Volume: ";
  25. cin >> (list + i)->volume;
  26. cout << "Consumption: ";
  27. cin >> (list + i)->consumption;
  28. }
  29.  
  30. cout << endl << endl;
  31. int cnt = 0;
  32. for (int i = 0; i < size; ++i) {
  33. if ((list + i)->consumption < 10) ++cnt;
  34. if ((list + i)->volume > 3) {
  35. cout << "Auto " << i + 1
  36. << "\nMake: " << (list + i)->make
  37. << "\nYear: " << (list + i)->year
  38. << "\nVolume: " << (list + i)->volume
  39. << "\nConsumption: " << (list + i)->consumption
  40. << endl;
  41. }
  42. }
  43.  
  44. cout << "The number of cars with consumption less than 10l: " << cnt << endl;
  45.  
  46. delete[] list;
  47. return 0;
  48. }
  49.  
  50. /*
  51. stdin:
  52. 5
  53. Zalupa
  54. 2006
  55. 5.5
  56. 30
  57. Sobaka
  58. 1966
  59. 1.9
  60. 5.6
  61. Huj
  62. 2001
  63. 3.3
  64. 25
  65. Abbbababab
  66. 0000
  67. 99999
  68. 0
  69. bbb
  70. 1812
  71. 2.2
  72. 1
  73. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement