ASCII mezi znaky


/ Published in: Java
Save to your folder(s)

Napište program jehož vstupem jsou dva znaky. Program poté vypíše všechny znaky, jejichž hodnoty jsou mezi hodnotami zadaných znaků.


Copy this code and paste it in your HTML
  1. import java.util.Scanner;
  2.  
  3. public class ASCIICviceni­{
  4. public static void main(String[] args){
  5. Scanner sc = new Scanner(System.in);
  6. String a = sc.next();
  7. String b = sc.next();
  8.  
  9. char o = a.charAt(0);
  10. char p = b.charAt(0);
  11.  
  12. int x = (int)o;
  13. int y = (int)p;
  14.  
  15. if(x < y){
  16. for(int i = x + 1; i < y; i++){
  17. System.out.println((char)i);
  18. }
  19. }else{
  20. for(int i = y + 1; i < x; i++){
  21. System.out.println((char)i);
  22. }
  23. }
  24. }
  25. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.