Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int Size,i,j,temp,a=0;
- cout << "Input Array Size: ";
- cin >> Size;
- int Num[Size];
- cout << "Input Values....\n";
- for(i=0; i<Size; i++)
- {
- cin >> Num[i];
- }
- for(i=0; i<Size; i++)
- {
- for(j=a; j<Size-1; j++)
- {
- if(Num[j] > Num[j+1])
- {
- temp = Num[j];
- Num[j] = Num[j+1];
- Num[j+1] = temp;
- a++;
- }
- }
- }
- cout << "\nAfter Sorting..." <<endl;
- for(i=0; i<Size; i++)
- {
- cout << Num[i] << " ";
- }
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment