fork download
  1. import java.util.Scanner;
  2.  
  3. class Pr
  4. {
  5. public static void main (String[] args)
  6. {
  7. Scanner in = new Scanner(System.in);
  8. String str;
  9. str=in.nextLine();
  10. while(str.indexOf(" ")!= -1){
  11. str=str.replaceAll(" "," ");
  12. }
  13. str=str.trim();
  14. int k=0;
  15. for(int i=0;i<str.length();i++){
  16. if(str.charAt(i)==' ')k++;
  17. }
  18. String[] m=new String[k+1];
  19. m=str.split(" ");
  20. int f=1;
  21. for(int i=0;i<k+1;i++){
  22. f=1;
  23. for(int j=0;j<m[i].length();j++){
  24. if (!(m[i].charAt(j)=='1' || m[i].charAt(j)=='0'|| m[i].charAt(j)=='2' || m[i].charAt(j)=='3' || m[i].charAt(j)=='4' || m[i].charAt(j)=='5' || m[i].charAt(j)=='6' || m[i].charAt(j)=='7' || m[i].charAt(j)=='8' || m[i].charAt(j)=='9' ))f=0;
  25.  
  26. }
  27. if (f==0){
  28. m[i]="j";
  29. }
  30. }
  31. k=0;
  32. for(int i=0;i<k+1;i++)
  33. if(m[i]!="-1")
  34. k=k+1;
  35. int[] q=new int[k];
  36. int g=0;
  37. for(int i=0;i<k+1;i++)
  38. System.out.print(m[i]);
  39. /*for(int i=0;i<k+1;i++)
  40.  
  41. if(m[i]!="j"){
  42. q[g]=Integer.parseInt(m[i]);
  43. g++;
  44. }
  45. for(int i=0;i<k-1;i++)
  46. for(int j=i+1;j<k;i++){
  47. if(q[i]>q[j]){
  48. int t=q[i];
  49. q[i]=q[j];
  50. q[j]=t;
  51. }
  52. }
  53. for(int i=0;i<k;i++)
  54. System.out.print(q[i]);*/
  55. }
  56. }
Runtime error #stdin #stdout #stderr 0.06s 4386816KB
stdin
У Миши было 10 конфет. 7 из них он о
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
	at Pr.main(Main.java:33)