|
|
back to boardDiscussion of Problem 1068. SumAccepted in C++ #include<bits/stdc++.h> #include<math.h> using namespace std; int main() { int N, sum = 0; cin>> N; if(N > 0) { for(int i = 1; i <= N; i++) { sum = sum + i; } } else if(N <= 0) { for(int i = N; i <= 1; i++) { sum = sum + i; } } cout<< sum << endl; return 0; } |
|
|