Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <set>
  6. #include <string>
  7. using namespace std;
  8. int n, i ,a ,b ,c ,f ,t ,y;
  9. long long x;
  10. char str[20];
  11.     class pr_aff {
  12.    private:
  13.     char ml;
  14.     long long mn;
  15.     string name,sname,date;
  16.    public: char Ml ()const{return ml;}
  17.    long long Mn()const{return mn;}
  18.     string  Name()const{return name;}
  19.     string  SName()const{return sname;}
  20.     string  Date()const{return date;}
  21.    };
  22.    struct cmp{
  23.     bool operator()(const pr_aff& a, const pr_aff& b) const{
  24.        
  25.        int i=0;
  26.         if (a.Mn() != b.Mn()) return a.Mn() < b.Mn();
  27.         if (a.Ml() != b.Ml()) return a.Ml() < b.Ml();
  28.         while(a.Sname()==b.Sname())
  29.             i++;
  30.         return(a.Sname()<b.Sname());
  31.         }
  32.        
  33.        };
  34.    
  35.    // pr_aff p;
  36.  /*   bool cl(Point x ,Point y)
  37.     {
  38.         int i=0;
  39.         if (x.mn != y.mn) return x.mn < y.mn;
  40.         if (x.ml != y.ml) return x.ml < y.ml;
  41.         while(x.sname[i]==y.sname[i])
  42.             i++;
  43.         return(x.sname[i]<y.sname[i]);
  44.         }*/
  45.     int main()
  46.     {
  47.     std::set<pr_aff,cmp> myset;
  48.     pr_aff p;
  49.     cin>>n;
  50.     for(i=0;i<=n-1;i++)
  51.     {
  52.         cin>>myset[i].Sname();
  53.         cin>>myset[i].Name();
  54.         cin>>str;
  55.         cin>>myset[i].Date();
  56.         int j=0;
  57.         a=0;
  58.         while(str[j]>='0' && str[j]<='9')
  59.         {
  60.             a++;
  61.             j++;
  62.         }
  63.         x=0;
  64.         for(int j=0;j<=a-1;j++)
  65.             x=x*10+int(str[j])-int('0');
  66.         myset[i].Mn()=x;
  67.         myset[i].Ml()=str[a];
  68.     }
  69.     for(i=0;i<=n-1;i++)
  70.     {
  71.         cout<<myset[i].Mn()<<myset[i].Ml()<<" "<<myset[i].Sname()<<" "<<myset[i].Name()<<" "<<myset[i].Date<<"\n";
  72.     }
  73.     return 0;
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement