Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) { int i=0, d=0, c=0;
  4.  
  5.  
  6.  
  7.         Scanner sc = new Scanner(System.in);
  8.         System.out.println("введите наименьшее число");
  9.        int a =sc.nextInt();
  10.         System.out.println("введите второе число диапозона");
  11.         int b =sc.nextInt();
  12.         System.out.println("диапозон");
  13.         while ((a + i) <= b) {
  14.             if ((a + i) % 2 == 1) {
  15.                  d  = d + a + i;
  16.             }
  17.             if (((a + 1)) % 2 == 1) {
  18.                c = c + a + i;
  19.             }
  20.             if (d > c) ;
  21.             System.out.println("Больше сумма чётных чисел " + d);
  22.         }
  23.         if (d < c) {
  24.             System.out.println("Больше сумма нечетных чисел" + 'с');
  25.         }
  26.         if (d == c) {
  27.             System.out.println("Обе суммы равны" + 'с');
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement