rakcode1998

Untitled

Jan 15th, 2017
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.26 KB | None | 0 0
  1. package a2oj;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.io.InputStreamReader;
  9. import java.io.OutputStream;
  10. import java.io.PrintWriter;
  11. import java.util.Arrays;
  12. import java.util.Comparator;
  13. import java.util.StringTokenizer;
  14.  
  15. /**
  16.  * Created by rakshit on 7/1/17.
  17.  * Java is Love and Code is Beautiful..
  18.  */
  19. public class Laptop {
  20.  
  21.     static class InputReader
  22.     {
  23.         public BufferedReader reader;
  24.         public StringTokenizer tok;
  25.  
  26.         public InputReader(InputStream inputStream)
  27.         {
  28.             reader =new BufferedReader(new InputStreamReader(inputStream));
  29.             tok=null;
  30.         }
  31.  
  32.         public InputReader(String inputFile) throws FileNotFoundException
  33.         {
  34.             reader=new BufferedReader(new FileReader(inputFile));
  35.             tok=null;
  36.         }
  37.  
  38.         public String nextLine()
  39.         {
  40.             String c="";
  41.             try
  42.             {
  43.                 c+=reader.readLine();
  44.             }
  45.             catch(IOException e)
  46.             {
  47.                 throw new RuntimeException(e);
  48.             }
  49.  
  50.             return c;
  51.         }
  52.  
  53.         public String next()
  54.         {
  55.             while(tok==null || !tok.hasMoreTokens())
  56.             {
  57.                 try
  58.                 {
  59.                     tok=new StringTokenizer(nextLine());
  60.                 }
  61.                 catch(Exception e)
  62.                 {
  63.                     throw new RuntimeException(e);
  64.                 }
  65.             }
  66.  
  67.             return tok.nextToken();
  68.         }
  69.  
  70.         public int nextInt()
  71.         {
  72.             return Integer.parseInt(next());
  73.         }
  74.  
  75.         public long nextLong()
  76.         {
  77.             return Long.parseLong(next());
  78.         }
  79.  
  80.         public double nextDouble()
  81.         {
  82.             return Double.parseDouble(next());
  83.         }
  84.     }
  85.  
  86.     public static void main(String args[])
  87.     {
  88.         InputStream inputstream=System.in;
  89.         OutputStream outputstream=System.out;
  90.         InputReader in=new InputReader(inputstream);
  91.         PrintWriter out=new PrintWriter (outputstream);
  92.         Task solver=new Task();
  93.         solver.solve(in,out);
  94.     }
  95.  
  96.     static class Task
  97.     {
  98.         public void solve(InputReader in , PrintWriter out)
  99.         {
  100.             int n=in.nextInt();
  101.  
  102.             Store store[]=new Store[n];
  103.             int a,b,c,d;
  104.  
  105.             for(int i=0 ;i<n ;i++)
  106.             {
  107.                 a=in.nextInt();
  108.                 b=in.nextInt();
  109.                 c=in.nextInt();
  110.                 d=in.nextInt();
  111.  
  112.                 store[i].set1(a);
  113.                 store[i].set2(b);
  114.                 store[i].set3(c);
  115.                 store[i].set4(d);
  116.             }
  117.  
  118.             Arrays.sort(store, new comparator());
  119.  
  120.             for(int i=0 ;i<n ;i++)
  121.             {
  122.                 out.println(store[i].get1()+" "+store[i].get2()+" "+store[i].get3()+" "+store[i].get4());
  123.             }
  124.             out.flush();
  125.         }
  126.     }
  127.  
  128.     static class Store
  129.     {
  130.         private static int a;
  131.         private static int b;
  132.         private static int c;
  133.         private static int d;
  134.  
  135.         public Store(int a, int b,int c,int d)
  136.         {
  137.             this.a=a;
  138.             this.b=b;
  139.             this.c=c;
  140.             this.a=a;
  141.         }
  142.  
  143.         public int get1()
  144.         {
  145.             return a;
  146.         }
  147.  
  148.         public int get2()
  149.         {
  150.             return b;
  151.         }
  152.  
  153.         public int get3()
  154.         {
  155.             return c;
  156.         }
  157.  
  158.         public int get4()
  159.         {
  160.             return d;
  161.         }
  162.  
  163.         public void set1(int a)
  164.         {
  165.             this.a=a;
  166.         }
  167.  
  168.         public void set2(int b)
  169.         {
  170.             this.b=b;
  171.         }
  172.  
  173.         public void set3(int c)
  174.         {
  175.             this.c=c;
  176.         }
  177.  
  178.         public void set4(int d)
  179.         {
  180.             this.d=d;
  181.         }
  182.     }
  183.  
  184.      static class comparator implements Comparator<Store>
  185.      {
  186.         public int compare(Store one, Store two)
  187.         {
  188.             if(one.a<two.a)
  189.             {
  190.                 return -1;
  191.             }
  192.             else if(one.a>two.a)
  193.             {
  194.                 return 1;
  195.             }
  196.             else
  197.             {
  198.                 if(one.b<two.b)
  199.                 {
  200.                     return -1;
  201.                 }
  202.                 else if(one.b>two.b)
  203.                 {
  204.                     return 1;
  205.                 }
  206.                 else
  207.                 {
  208.                     if(one.c<two.c)
  209.                     {
  210.                         return -1;
  211.                     }
  212.                     else if(one.c>two.c)
  213.                     {
  214.                         return 1;
  215.                     }
  216.                     else
  217.                     {
  218.                         if(one.d<two.d)
  219.                         {
  220.                             return -1;
  221.                         }
  222.                         else if(one.d>two.d)
  223.                         {
  224.                             return 1;
  225.                         }
  226.                         else
  227.                             return 0;
  228.                     }
  229.                 }
  230.             }
  231.         }
  232.     }
  233. }
Add Comment
Please, Sign In to add comment