Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a , b=0;
- cout << "enter array size " ;
- cin>>a;
- int x[a+2];
- for(int i;i<a;i++){
- cin>>x[i];
- }
- cout<<" array is : ";
- for(int j;j<a;j++ ){
- cout<<x[j]<<" ";
- }
- cout<<endl;
- cout<<endl;
- //sort(x, x + a, greater<int>());
- for(int i=0;i<a;i++)
- {
- for(int j=i+1;j<a;j++)
- {
- if(x[i]<x[j])
- {
- b =x[i];
- x[i]=x[j];
- x[j]=b;
- }
- }
- }
- cout<<" In descending order : "<<endl;
- cout<<endl;
- cout<<" array is : ";
- for(int k;k<a;k++ ){
- cout<<x[k]<<" ";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment