Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int main()
- {
- int element;
- cout<<"Obliczam wskazany element ciagu liczbowego"<<endl;
- start:
- cout<<"Podaj, element ciagu liczbowego, ktory nalezy obliczyc = ";
- cin>>element;
- if(element<=1)
- {cout<<"Liczba musi byc wieksza od 1"<<endl;
- goto start;}
- int x[element];
- int a=2;
- x[0]=3;
- for(;;)
- {
- x[a-1]=x[a-2]+(a*a);
- if(a==element)
- {
- cout<<"Ciag("<<element<<")="<<x[a-1]<<endl;
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- a++;
- }
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement