#include"stdio.h"
#include"iostream"
using namespace std;
#define f(x) 4.0/(1+(x)*(x))
void main()
{
float h = (1.0 - 0) / 4, temp, xk, yk, xkh, ykh, xk1, yk1;
int i;
temp = f(0); xk = 0;
for (i = 1; 1 < 4; i++);
{
xk = xk + h;
temp = temp + 2 * f(xk);
}
temp = temp + f(1);
temp = temp * h / 2;
printf(" \n復化梯形公式計算的結果: %f", temp);
temp = 0; h = (1.0 - 0) / 2; // 對復化simpson公式分成2個小區間
xk = 0; yk = f(0); //xk-- x[k]
for (i = 0; i < 2; i++)
{
xkh = xk + h / 2; ykh = f(xkh);
//xkh-- x[k+1/2]
xk1 = xk + h; yk1 = f(xk1);
//xk1-- x[k+1]
temp = temp + h*(yk + 4 * ykh + yk1) / 6; // 加上每個小區間上的面積
xk = xk1;
yk = yk1;
}
//右端點是下一個小區間的左端點
printf("\n復化simpson公式計算的結果: %f\n", temp);
system("pause");
}
uj5u.com熱心網友回復:
下個斷點單步執行看看uj5u.com熱心網友回復:
斷點單步是啥轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/58150.html
標籤:新手樂園
上一篇:sysfer.dll例外,客戶端應用退出,日志基本看不到什么有用的資訊
下一篇:使用G0寫亂數時遇到的問題
