Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) { int i=0, d=0, c=0;
- Scanner sc = new Scanner(System.in);
- System.out.println("введите наименьшее число");
- int a =sc.nextInt();
- System.out.println("введите второе число диапозона");
- int b =sc.nextInt();
- System.out.println("диапозон");
- while ((a + i) <= b) {
- if ((a + i) % 2 == 1) {
- d = d + a + i;
- }
- if (((a + 1)) % 2 == 1) {
- c = c + a + i;
- }
- if (d > c) ;
- System.out.println("Больше сумма чётных чисел " + d);
- }
- if (d < c) {
- System.out.println("Больше сумма нечетных чисел" + 'с');
- }
- if (d == c) {
- System.out.println("Обе суммы равны" + 'с');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement