Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- class Ascii
- {
- public:
- int cod;
- public:
- friend ostream & operator << (ostream &out, const Ascii &c);
- friend istream & operator >> (istream &in, Ascii &c);
- bool operator < ( const Ascii& val ) const {
- return cod < val.cod;
- }
- };
- struct Asciigreater
- {
- bool operator()( const Ascii& lx, const Ascii& rx ) const {
- return lx.cod < rx.cod;
- }
- };
- ostream & operator << (ostream &out, const Ascii &c)
- {
- out << char(c.cod) << " ";
- return out;
- }
- istream & operator >> (istream &in, Ascii &c)
- {
- in >> c.cod;
- return in;
- }
- int main()
- {
- Ascii c1;
- int v[100];
- int n=0;
- ifstream f("in.txt");
- ofstream g1("out1.txt");
- while(f >> c1){
- g1 << c1;
- v[n++]=c1.cod;
- }
- int aux;
- for(int i=0;i<n;i++)
- for(int j=i+1;j<n;j++){
- if(v[i]<v[j]){
- aux=v[i];
- v[i]=v[j];
- v[j]=aux;
- }
- }
- ofstream g2("out2.txt");
- n--;
- while(n>=0){
- g2 << char(v[n]) << " ";
- n--;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement