Guest User

Untitled

a guest
Oct 21st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4.  
  5. public class H {
  6. static BufferedReader input;
  7. static StringTokenizer _stk;
  8. static String readln() throws IOException {
  9. String l = input.readLine();
  10. if(l!=null) _stk = new StringTokenizer(l, " ");
  11. return l;
  12. }
  13. static String next() { return _stk.nextToken(); }
  14. static int nextInt() { return Integer.parseInt(next()); }
  15.  
  16. public static void main(String[] args) throws IOException {
  17. Locale.setDefault(Locale.US);
  18. File asd = new File("book.in");
  19. input = new BufferedReader(new FileReader(asd));
  20. String lineaActual;
  21. int casos=0;
  22. lineaActual = readln();
  23. while(true){
  24. casos++;
  25. int inicial=nextInt();
  26. int end=nextInt();
  27. if(inicial>end){
  28. int tmp=end;
  29. end=inicial;
  30. inicial=tmp;
  31. }
  32. String numeros="";
  33. for(;inicial<=end;inicial++){
  34. numeros+=inicial;
  35. }
  36. int arreglo[] = new int[10];
  37. for(int i=0;i<numeros.length();i++){
  38. arreglo[((int)numeros.charAt(i))-48]++;
  39. }
  40. System.out.print("Case "+casos+": ");
  41. for(int i=0;i<arreglo.length;i++){
  42. System.out.print(i+":"+arreglo[i]);
  43. if(i!=arreglo.length-1) System.out.print(" ");
  44. }
  45. lineaActual = readln();
  46. if(lineaActual.equals("0")) return;
  47. else System.out.println();
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment