#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
bool anik(int a, int b)
{
return (a>b);
}
using namespace std;
int main()
{
vector<int> ar;
vector<int> :: iterator an;
int n, i, m;
cout << "Enter Vector Element Number :: ";
cin >> n;
cout << "\nEnter Vector Element :: ";
for(i=1;i<=n;i++)
{
cin >> m;
ar.push_back(m);
}
cout << endl;
sort(ar.begin(), ar.end());
for(an = ar.begin();an != ar.end();an++)
{
cout << *an << "\t";
}
cout << endl << endl;
sort(ar.begin(), ar.end(), anik);
for(an = ar.begin(); an!= ar.end(); an++)
{
cout << *an << "\t";
}
cout << endl;
return 0;
}
#include<vector>
#include<algorithm>
#include<iterator>
bool anik(int a, int b)
{
return (a>b);
}
using namespace std;
int main()
{
vector<int> ar;
vector<int> :: iterator an;
int n, i, m;
cout << "Enter Vector Element Number :: ";
cin >> n;
cout << "\nEnter Vector Element :: ";
for(i=1;i<=n;i++)
{
cin >> m;
ar.push_back(m);
}
cout << endl;
sort(ar.begin(), ar.end());
for(an = ar.begin();an != ar.end();an++)
{
cout << *an << "\t";
}
cout << endl << endl;
sort(ar.begin(), ar.end(), anik);
for(an = ar.begin(); an!= ar.end(); an++)
{
cout << *an << "\t";
}
cout << endl;
return 0;
}
Comments
Post a Comment