AreWe

suleiman 2 fix

Mar 9th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include <string>
  4.  
  5. struct SBicycle
  6. {
  7. string model;
  8. int speeds;
  9. int wheelDiam;
  10. };
  11.  
  12. void Func2(SBicycle *a, int len, int speeds) // в)
  13. {
  14. cout << "Диаметри на колела,които се срещат при поне 2 различни модела:" << endl;
  15. for (int i = 0; i < len; i++)
  16. {
  17. bool check = false;
  18. bool checkOut = true;
  19.  
  20. if (a[i].speeds == speeds)
  21. {
  22. for (int j = 0; j < len; j++)
  23. {
  24. if ((a[i].wheelDiam == a[j].wheelDiam && a[i].model.compare(a[j].model) != 0) && j != i)
  25. {
  26. check = true;
  27. for (int k = 0; k < i; k++)
  28. {
  29. if (a[i].wheelDiam == a[k].wheelDiam)
  30. {
  31. checkOut = false;
  32. }
  33. }
  34. }
  35. }
  36. if(check && checkOut) cout << a[i].wheelDiam << " ";
  37. }
  38. }
  39. cout << "\n\n";
  40. }
  41.  
  42. int main()
  43. {
  44. system("chcp 1251 >> nul");
  45.  
  46. const int br = 6;
  47.  
  48. SBicycle bicycles[br];
  49.  
  50. bicycles[0].model = "Model1";
  51. bicycles[0].speeds = 18;
  52. bicycles[0].wheelDiam = 26;
  53.  
  54. bicycles[1].model = "Model2";
  55. bicycles[1].speeds = 16;
  56. bicycles[1].wheelDiam = 24;
  57.  
  58. bicycles[2].model = "Model3";
  59. bicycles[2].speeds = 18;
  60. bicycles[2].wheelDiam = 26;
  61.  
  62. bicycles[3].model = "Model4";
  63. bicycles[3].speeds = 12;
  64. bicycles[3].wheelDiam = 26;
  65.  
  66. bicycles[4].model = "Model5";
  67. bicycles[4].speeds = 14;
  68. bicycles[4].wheelDiam = 24;
  69.  
  70. bicycles[5].model = "Model6";
  71. bicycles[5].speeds = 18;
  72. bicycles[5].wheelDiam = 26;
  73.  
  74. Func2(bicycles, br, 18);
  75.  
  76. system("pause");
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment