kirya_shkolnik

Вася, почини код

Dec 10th, 2020 (edited)
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void Pos(double& sum,int& n)
  6. {
  7.     n=1;
  8.     double a=1;
  9.     cout<<"\tВычисление членов последовательности: "<<endl;
  10.     cout<<"\tномер \tзначение "<<endl;
  11.     while (a>0 && sum<4)
  12.     {
  13.         cout<<'\t'<<n<<'\t'<<'\t'<<sum<<endl;
  14.         a=a*(sqrt(n)/sqrt(n+1));
  15.         sum = sum+a;
  16.         n++;
  17.     }
  18. }
  19.  
  20. void GETN(int& n)
  21. {
  22.     setlocale(LC_ALL,"rus");
  23.     cout<<"Введите n ";
  24.     cin>>n;
  25. }
  26. void PUTXN(double sum, int n){
  27.     cout << "При n = "<< n << endl;
  28.     cout << "Значение выражения = " << sum << endl;
  29.     cout << n << "- является минимальным n при котором выражение больше 4" << endl << endl;
  30. }
  31. int main()
  32. {
  33.     int n;
  34.     double sum =1;
  35.     GETN(n);
  36.     Pos(sum,n);
  37.     PUTXN(sum,n);
  38.     return 0;
  39. }
Add Comment
Please, Sign In to add comment