Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void InsertionMax(int array[], int size)
- {
- for (int i = 0; i<size - 1; i++)
- {
- int j = i + 1;
- int tmp = array[j];
- while (j>0 && tmp > array[j - 1])
- {
- array[j] = array[j - 1];
- j--;
- }
- array[j] = tmp;
- }
- }
- void InsertionMin(int array[], int size)
- {
- for (int i = 0; i<size - 1; i++)
- {
- int j = i + i;
- int tmp = array[j];
- while (j>0 && tmp <array[j - 1])
- {
- array[j] = array[j - 1];
- j--;
- }
- array[j] = tmp;
- }
- }
- void Printo(int A[])
- {
- for (int i = 0; i<5; i++)
- {
- cout << A[i] <<" ,";
- }
- }
- void GjejElement(int A[])
- {
- int x;
- cout <<"Sheno indexin e cilit numer deshiron ta gjesh : ";
- cin >>x;
- for (int i=0;i<5;i++)
- {
- if (A[i]==x)
- {
- cout << "Vlera :" <<i<<endl;
- }
- }
- }
- int main()
- {
- int x;
- cout << "Sheno vleren :";
- int A[x]={};
- for (int i = 0; i<5; i++)
- {
- cout << "Sheno vleren :";
- cin >> x;
- A[i]=x;
- }
- Printo(A);
- cout <<"\n\n"<<endl;
- InsertionMax(A, 5);
- Printo(A);
- cout <<"\n\n"<<endl;
- InsertionMin(A, 5);
- Printo(A);
- GjejElement(A);
- return 0;
- }
Add Comment
Please, Sign In to add comment