Facebook
From kutelans, 3 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 65
  1. //C#:
  2.  
  3.  
  4.         //Standard bemenetrol szam beolvasas:
  5.        
  6.         long a, b;
  7.         string s = Console.ReadLine();
  8.         string[] szamok = s.Split(' ');
  9.         a = Convert.ToInt32(szamok[0]);
  10.         b = Convert.ToInt32(szamok[1]);
  11.        
  12.  
  13.         //EOF-ig while:
  14.        
  15.     string x;
  16.         x =  Console.ReadLine();
  17.  
  18.     while (true)
  19.     {
  20.         if (x == null) break;
  21.         x = Console.ReadLine();
  22.     }
  23.        
  24.        
  25.         //Split hasznalata:
  26.        
  27.         string par;
  28.         par = Console.ReadLine();
  29.     string[] s = par.Split(' ');
  30.        
  31.        
  32.         //Float formazas:
  33.        
  34.         // just two decimal places
  35.         String.Format("{0:0.00}", 123.4567);      // "123.46"
  36.         String.Format("{0:0.00}", 123.4);         // "123.40"
  37.        
  38.         // max. two decimal places
  39.         String.Format("{0:0.##}", 123.4567);      // "123.46"
  40.         String.Format("{0:0.##}", 123.4);         // "123.4"
  41.  
  42.         //thousands separator
  43.         String.Format("{0:0,0.0}", 12345.67);     // "12,345.7"
  44.         String.Format("{0:0,0}", 12345.67);       // "12,346"
  45.  
  46.        
  47.  
  48. //Java:
  49.        
  50.        
  51.         //Standard bemenetrol scanner hasznalata:
  52.        
  53.         Scanner sc = new Scanner(System.in);
  54.         String s=sc.nextLine();
  55.        
  56.  
  57.         //Int-e alakitas:
  58.        
  59.         int x=Integer.parseInt(sc.nextLine());
  60.        
  61.        
  62.         //SPACE szerint splitteles:
  63.        
  64.         String par=sc.nextLine();
  65.     s = par.split("\\s");
  66.        
  67.        
  68.         //Ket string osszehasonlitasa:
  69.        
  70.         s.equals("Valami");
  71.  
  72.  
  73.         //String.Format:
  74.  
  75.         System.out.println(String.format( "%.2f" ,x ));
  76.