|
|
back to boardDiscussion of Problem 1068. SumWhat's wrong? c++, Posted by VNeo 8 Jun 2017 13:06 #include <iostream> using namespace std; int main() { int a,b; cin >>a; if (a>=1){ for (int i=1;i<=a;i++){ b=b+i; } } else if (a<1){ for (int i=1;i>=a;i--){ b=b+i; } } cout<<b; } i tested with test case #1 it work, but after submit the judge says wrong answer test 1, why? Re: What's wrong? c++, b initial value is? Do you use gcc? Probably "-Wuninitialized" option can help. |
|
|