Advertisement
Pafnytiu

рек - 14 СДАТЬ

Nov 17th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3. #include<iomanip>
  4. using namespace std;
  5. int main()
  6. {
  7. float a1 = 2, a2 = 1, a;
  8. int n;
  9. cin >> n;
  10. if (n == 1)
  11. {cout<<"a1="<<a1<<endl;}
  12. if (n == 2)
  13. {cout<<"a1="<<a1<<endl<<"a2="<<a2<<endl;}
  14.  
  15. if (n>=3)
  16. {{cout<<"a1=2"<<endl<<"a2=1"<<endl;}
  17. for (int i = 3; i <= n; i++)
  18. {
  19. a=(((2.0/3.0)*a1)-((1.0/3.0)*(pow(a2,2))));
  20. a1=a2; a2=a;
  21. cout<<setprecision(10)<<"a"<<i<<"="<<a<<endl;}}
  22. system("pause");
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement