Advertisement
Zuneve

hqtad1

Oct 14th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int n, summa=0;
  5. cin >> n;
  6. if (n>0) {
  7. for (int i = 1; i<=n; i++) {
  8. summa+=i;
  9. }
  10. }
  11. if (n<=0) {
  12. for (int i=1; i>=n; i--) {
  13. summa+=i;
  14. }
  15. }
  16. cout << summa;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement