delvinkrasniqi

Untitled

Nov 26th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void InsertionMax(int array[], int size)
  5. {
  6. for (int i = 0; i<size - 1; i++)
  7. {
  8. int j = i + 1;
  9. int tmp = array[j];
  10. while (j>0 && tmp > array[j - 1])
  11. {
  12. array[j] = array[j - 1];
  13. j--;
  14. }
  15. array[j] = tmp;
  16. }
  17. }
  18.  
  19. void InsertionMin(int array[], int size)
  20. {
  21. for (int i = 0; i<size - 1; i++)
  22. {
  23. int j = i + i;
  24. int tmp = array[j];
  25. while (j>0 && tmp <array[j - 1])
  26. {
  27. array[j] = array[j - 1];
  28. j--;
  29. }
  30. array[j] = tmp;
  31. }
  32. }
  33.  
  34. void Printo(int A[])
  35. {
  36. for (int i = 0; i<5; i++)
  37. {
  38. cout << A[i] <<" ,";
  39. }
  40. }
  41.  
  42. void GjejElement(int A[])
  43. {
  44. int x;
  45. cout <<"Sheno indexin e cilit numer deshiron ta gjesh : ";
  46. cin >>x;
  47. for (int i=0;i<5;i++)
  48. {
  49. if (A[i]==x)
  50. {
  51. cout << "Vlera :" <<i<<endl;
  52. }
  53. }
  54.  
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62. int main()
  63. {
  64.  
  65. int x;
  66. cout << "Sheno vleren :";
  67. int A[x]={};
  68. for (int i = 0; i<5; i++)
  69. {
  70. cout << "Sheno vleren :";
  71. cin >> x;
  72. A[i]=x;
  73.  
  74. }
  75.  
  76.  
  77.  
  78. Printo(A);
  79. cout <<"\n\n"<<endl;
  80.  
  81. InsertionMax(A, 5);
  82. Printo(A);
  83. cout <<"\n\n"<<endl;
  84.  
  85. InsertionMin(A, 5);
  86. Printo(A);
  87.  
  88. GjejElement(A);
  89.  
  90.  
  91.  
  92.  
  93. return 0;
  94. }
Add Comment
Please, Sign In to add comment