fork download
  1. import java.util.*;
  2. class Ascii
  3. {
  4. public static void main(String arg[])
  5. {
  6. Scanner s=new Scanner(System.in);
  7. String str=s.nextLine();
  8. int x=0;
  9. char[] c=str.toCharArray();
  10. int loopcount=0;
  11. int count=0;
  12. int f=0;
  13. for(int i=0;i<c.length;i++)
  14. {
  15. System.out.println(c[i]+" "+i);
  16. boolean flag=true;
  17. for(int k=0;k<i;k++){
  18. if(c[i]==(str.charAt(k)))
  19. flag=false;
  20. }
  21. if(flag){
  22. for(int j=0;j<str.length();j++)
  23. {
  24. if(c[i]==str.charAt(j))
  25. count=count+1;
  26. }
  27. int inx=(int)c[i]-96;
  28. if(inx==count)
  29. {
  30. f=f+1;
  31. }
  32. else
  33. {
  34. f=0;
  35. }
  36. System.out.println(c[i]+" "+" "+(count));
  37. count=0;
  38. loopcount++;
  39. x++;
  40. }
  41. System.out.println("X value: "+x);
  42. }
  43. if(f==x)
  44. System.out.println("Yes");
  45. else
  46. System.out.println("No");
  47. }
  48. }
Success #stdin #stdout 0.16s 321344KB
stdin
1
abb
stdout
1 0
1  1
X value:  1
No