|
|
вернуться в форумCan you please tell me what's am wrong? Послано Axeus 21 мар 2011 16:04 import java.util.Scanner; public class Sum { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); if(num < 0){ num = Math.abs(num); num = ((num*(num+1)/2)-1)*-1; System.out.println(num); }else if(num > 0 && num < 10000){ num = num*(num+1)/2; System.out.println(num); }else if(num == 0){ num = 1; System.out.println(num); } System.out.flush(); } } Re: Can you please tell me what's am wrong? Do not use scanner classes. I got WA for a program. Use the bufferedreader and then parse it. |
|
|