Skip to content

Instantly share code, notes, and snippets.

@avevlad
Created October 25, 2013 21:22
Show Gist options
  • Save avevlad/7162049 to your computer and use it in GitHub Desktop.
Save avevlad/7162049 to your computer and use it in GitHub Desktop.
#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