Advertisement
labyyysosaaat

Untitled

Oct 11th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <locale>
  4. #include <cmath>
  5. using namespace std;
  6. int main()
  7. {
  8.  
  9. setlocale(LC_ALL, ".1251");
  10. cout.precision(10);
  11. cout << "" << endl;
  12. int proverka = 0;
  13. while (proverka <= 50)
  14. {
  15.  
  16. int chisl = 0;
  17. while (chisl == 0)
  18. {
  19. chisl = (rand() % 3) - 1;
  20. }
  21. int del = rand() % 10 + 1;
  22. double x = 1. * chisl / del;
  23. cout << "Великикй рандом выбрал х равный:" << x << endl;
  24.  
  25. double my_sin = 0;
  26. long long i = 1;
  27.  
  28. while (i < 10000000)
  29. {
  30. my_sin = my_sin + ((pow(-1, i - 1) * pow(x, 2 * i - 1)) / (2 * i - 1));
  31. i++;
  32. }
  33. cout << "sin(x) мой код посчитал так: " << my_sin << endl;
  34. cout << "sin(x) стандартная функция С++ посчитала так: " << sin(x) << endl;
  35. proverka++;
  36. break;
  37. }
  38. system("pause");
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement