Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <time.h>
- int main()
- {
- clock_t start_time = clock();
- for (int N = 2e7; N <= 2e8; N += 2e7)
- {
- double sum = 0,
- sum_cor = 0,
- cor = 0;
- for (double n = 1; n <= N; ++n)
- {
- double f = sqrt((7 + 3*n) / (5 + n));
- double fcor = f - cor;
- //сумма с коррекцией
- double temp_sum = sum_cor;
- sum_cor += fcor;
- cor = (sum_cor - temp_sum) - fcor;
- //простая сумма
- sum += f;
- }
- printf("%9d%18.4f%18.4f%10.4f\n", N, sum, sum_cor, sum - sum_cor);
- }
- clock_t end_time = clock();
- double execution_time = (end_time - start_time) / (double)CLK_TCK;
- printf("Time of execution: %lfs", execution_time);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment