Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int element;
  9. cout<<"Obliczam wskazany element ciagu liczbowego"<<endl;
  10. start:
  11. cout<<"Podaj, element ciagu liczbowego, ktory nalezy obliczyc = ";
  12. cin>>element;
  13. if(element<=1)
  14. {cout<<"Liczba musi byc wieksza od 1"<<endl;
  15. goto start;}
  16. int x[element];
  17. int a=2;
  18. x[0]=3;
  19. for(;;)
  20. {
  21. x[a-1]=x[a-2]+(a*a);
  22. if(a==element)
  23. {
  24. cout<<"Ciag("<<element<<")="<<x[a-1]<<endl;
  25. system("PAUSE");
  26. return EXIT_SUCCESS;
  27. }
  28. a++;
  29. }
  30. system("PAUSE");
  31. return EXIT_SUCCESS;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement