|
|
back to boardDiscussion of Problem 1068. SumГде ошибка? С++ Posted by NoNSoS 16 Jul 2015 12:49 #include <iostream> using namespace std; int main (){ int a; int sum; cin >> a; if (a<1 && a>=-10000){ for (int i = 1; i >= a; i--){ sum = sum + i; }; } else if (a>=1 && a<=10000) { for (int i = 1; i <= a; i++){ sum = sum + i;
}; }; cout << sum; return 0; } при: N(a) -- sum 10000 -- 50005000 1 -- 1 0 -- 1 -1 -- 0 -3 -- -5 -10000 -- 50004999 Edited by author 16.07.2015 12:55 Edited by author 16.07.2015 12:56 |
|
|