Posted By


Kollins on 03/01/13

Tagged


Statistics


Viewed 128 times
Favorited by 0 user(s)

Related snippets


Mezi dvěma čísly


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

Napište program, který vypíše všechna čísla mezi dvěma čísly, které zadá uživatel.


Copy this code and paste it in your HTML
  1. import java.util.Scanner;
  2.  
  3. public class VypisMeziCisly{
  4. public static void main(String[] args){
  5. System.out.println("Zadej dve cela¡ cisla: ");
  6. Scanner sc = new Scanner(System.in);
  7. int a = sc.nextInt();
  8. int b = sc.nextInt();
  9.  
  10. if(a < b){
  11. for(int i = a + 1; i < b; i++){
  12. System.out.println(i);
  13. }
  14. }else{
  15. for(int i = b + 1; i < a; i++){
  16. System.out.println(i);
  17. }
  18. }
  19. }
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.