Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- #include <cmath>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, ".1251");
- cout.precision(10);
- cout << "" << endl;
- int proverka = 0;
- while (proverka <= 50)
- {
- int chisl = 0;
- while (chisl == 0)
- {
- chisl = (rand() % 3) - 1;
- }
- int del = rand() % 10 + 1;
- double x = 1. * chisl / del;
- cout << "Великикй рандом выбрал х равный:" << x << endl;
- double my_sin = 0;
- long long i = 1;
- while (i < 10000000)
- {
- my_sin = my_sin + ((pow(-1, i - 1) * pow(x, 2 * i - 1)) / (2 * i - 1));
- i++;
- }
- cout << "sin(x) мой код посчитал так: " << my_sin << endl;
- cout << "sin(x) стандартная функция С++ посчитала так: " << sin(x) << endl;
- proverka++;
- break;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement