Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. /*
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. template <class t3,class t2>
  6. t2 porownanie (t3 a , t2 b)
  7. {
  8. if (a >= b)
  9. {
  10. return a;
  11. }
  12. else {
  13. return b;
  14. }
  15.  
  16. }
  17.  
  18. int main()
  19. {
  20. int a, b;
  21. cin >> a>> b;
  22. cout << porownanie(a, b);
  23. system("pause");
  24. }
  25. */
  26.  
  27. /*
  28. #include<iostream>
  29. #include<ctime>
  30. using namespace std;
  31.  
  32. template <class typ1, class typ2>
  33. typ1* bombel(typ1* a, typ2 b)
  34. {
  35. for (int i = 0; i < b; i++) {
  36. for (int j = 1; j < b-i; j++)
  37. {
  38. if (a[j - 1] > a[j]) {
  39. swap(a[j - 1], a[j]);
  40. }
  41. }
  42. }
  43. return a;
  44. }
  45.  
  46. int main()
  47. {
  48. srand(time(NULL));
  49. int n;
  50. cin >> n;
  51. cout << endl;
  52. int *tab = new int[n];
  53. for (int i = 0; i < n; i++)
  54. {
  55. tab[i] = rand() % 10;
  56. cout << tab[i] << endl;
  57. }
  58. cout << "-----------------------------------" << endl;
  59. bombel(tab, n);
  60. for (int i = 0; i < n; i++)
  61. {
  62. cout << tab[i] << endl;
  63. }
  64. system("pause");
  65. }
  66. */
  67. #include<iostream>
  68. #include<string>
  69. using namespace std;
  70.  
  71. struct osoba {
  72. int wiek;
  73. string imie;
  74. string nazwisko;
  75. };
  76.  
  77. template <class typ1, class typ2>
  78. typ1* bombel(typ1* a, typ2 b)
  79. {
  80. for (int i = 0; i < b; i++) {
  81. for (int j = 1; j < b - i; j++)
  82. {
  83. if (a[j - 1].wiek > a[j].wiek) {
  84. swap(a[j - 1], a[j]);
  85. }
  86. }
  87. }
  88. return a;
  89. }
  90.  
  91. int main()
  92. {
  93. int a;
  94. cout << "Wprowadz liczbe osob: ";
  95. cin >> a;
  96. cout << endl;
  97. osoba *tab = new osoba[a];
  98. for (int i = 0; i < a; i++)
  99. {
  100. cout << "Imie: ";
  101. cin >> tab[i].imie;
  102. cout << "Nazwisko: ";
  103. cin >> tab[i].nazwisko;
  104. cout << "Wiek: ";
  105. cin >> tab[i].wiek;
  106. }
  107. cout << endl << endl;
  108. for (int i = 0; i < a; i++)
  109. {
  110. cout << "Imie: ";
  111. cout<< tab[i].imie;
  112. cout << endl << "Nazwisko: ";
  113. cout<< tab[i].nazwisko;
  114. cout << endl << "Wiek: ";
  115. cout<< tab[i].wiek;
  116. cout << endl << endl;
  117. }
  118. system("pause");
  119.  
  120. bombel(tab, a);
  121. cout << endl << endl;
  122. for (int i = 0; i < a; i++)
  123. {
  124. cout << "Imie: ";
  125. cout << tab[i].imie;
  126. cout << endl << "Nazwisko: ";
  127. cout << tab[i].nazwisko;
  128. cout << endl << "Wiek: ";
  129. cout << tab[i].wiek;
  130. cout << endl << endl;
  131. }
  132. system("pause");
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement