delvinkrasniqi

Untitled

Nov 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 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. int main()
  62. {
  63. int A[5] = { 1, 5, 99, 43, 17 };
  64.  
  65. Printo(A);
  66. cout <<"\n\n"<<endl;
  67. InsertionMax(A, 5);
  68. Printo(A);
  69. cout <<"\n\n"<<endl;
  70.  
  71. InsertionMin(A, 5);
  72. Printo(A);
  73.  
  74.  
  75. GjejElement(A);
  76.  
  77.  
  78.  
  79.  
  80. return 0;
  81. }
Add Comment
Please, Sign In to add comment