Skip to content

Instantly share code, notes, and snippets.

@avevlad
Created Oct 25, 2013
Embed
What would you like to do?
#include <iostream>
using namespace std;
int main()
{
#ifdef _DEBUG
freopen("input.txt", "r",stdin);
freopen("output.txt", "w",stdout);
#endif
int num = 0;
int a;
cin >> a;
if (a < 1) {
while (a <= 1) {
num += a;
a++;
}
}
else {
while (a >= 1) {
num += a;
a--;
}
}
cout << num << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment