?? ch8_24.cpp
字號:
//**********************
//** ch8_24.cpp **
//**********************
#include <iostream.h>
#include <math.h>
double sigma(double(*func)(double), double dl, double du)
{
double dt=0.0;
for(double d=dl; d<du; d+=0.1)
dt += func(d); //用函數指針調用函數
return dt;
}
void main()
{
double dsum;
dsum=sigma(sin, 0.1, 1.0); //sin函數為實參賦給函數指針func
cout <<"the sum of sin from 0.1 to 1.0 is " <<dsum <<endl;
dsum=sigma(cos, 0.5, 3.0); //cos函數賦給函數指針func
cout <<"the sum of cos from 0.5 to 3.0 is " <<dsum <<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -