TÓPICO

5% wrong answer help me

supermanshuvo perguntou 4 years ago

when I test the code in my compiler it show me the right answer. Why in here i got 5% wrong ansere? please someone help me...

import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int X = in.nextInt(); int Y = in.nextInt(); if(X<0 && Y<0){ X = Math.abs(X); Y = Math.abs(Y); }else if(X<0){ X = Math.abs(X); }else if(Y<0){ Y = Math.abs(Y); } if(X>Y){ int temp = X; X = Y; Y = temp; } int sum = 0; for(int i = X;i<Y;i++){ if(i%2==1){ sum+=i; } } System.out.println(sum); } }

Lembre de não publicar soluções. Sua publicação pode ser revisada por nossos moderadores.

  • ithiago respondido 3 years ago

    The range is between the smallest of (x, y) + 1 and the largest of (x, y).

    =)