2011年2月18日金曜日

Aizu Online Judge 0136 Frequency Distribution of Height

■0136 Frequency Distribution of Height

やるだけ.

  1. import java.util.*;  
  2. import java.lang.*;  
  3. import java.math.*;  
  4. import java.io.*;  
  5.   
  6. import static java.lang.Math.*;  
  7. import static java.util.Arrays.*;  
  8.   
  9. public class Main{  
  10.   
  11.  Scanner sc=new Scanner(System.in);  
  12.   
  13.  int INF=1<<28;  
  14.  double EPS=1e-9;  
  15.   
  16.  void run(){  
  17.   int n=sc.nextInt();  
  18.   int[] a=new int[6];  
  19.   for(int i=0; i<n; i++){  
  20.    double d=sc.nextDouble();  
  21.    for(int k=0; k<6; k++){  
  22.     if(d+EPS<165+k*5||k==5){  
  23.      a[k]++;  
  24.      break;  
  25.     }  
  26.    }  
  27.   }  
  28.   for(int i=0; i<6; i++){  
  29.    print((i+1)+":");  
  30.    for(int k=0; k<a[i]; k++){  
  31.     print("*");  
  32.    }  
  33.    println("");  
  34.   }  
  35.  }  
  36.   
  37.  void debug(Object... os){  
  38.   System.err.println(Arrays.deepToString(os));  
  39.  }  
  40.   
  41.  void print(String s){  
  42.   System.out.print(s);  
  43.  }  
  44.   
  45.  void println(String s){  
  46.   System.out.println(s);  
  47.  }  
  48.   
  49.  public static void main(String[] args){  
  50.   // System.setOut(new PrintStream(new BufferedOutputStream(System.out)));  
  51.   new Main().run();  
  52.  }  
  53. }  

0 件のコメント: