|
|
back to boardDiscussion of Problem 1068. SumWA C++ 1068. Summa Posted by Necros 18 Oct 2013 22:59 what's wrong in my code: #include <iostream> int main() { int N; std::cin >> N; int result=0; if (N=0){ std::cout << 1 << std::endl; return 0; } if (N > 0) { for (int i=2; i<=N;i++) { result+=i; } std::cout << result << std::endl; return 0; }else { for (int i=-2;i >=N;i--) { result+=i; } std::cout << result << std::endl; return 0; } return 0; } Edited by author 18.10.2013 23:00 |
|
|