|
|
back to boardDiscussion of Problem 1068. SumWA#4 Posted by Marc 25 Mar 2012 23:54 import java.util.Scanner; public class Bil { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a = input.nextInt(); int b = numbers (Math.abs(a)); if (a >= 0 )System.out.println(b); else {System.out.println(-b);} } public static int numbers( int a){ int sum = 0; if (a > 1){ for (int i = 2; i <= a; i++) sum +=i; } // else if (a == 0) sum = 0; else{ sum = 1; } return sum; } } |
|
|