清华大学c--课件第3章说课材料.pptVIP

  • 3
  • 0
  • 约6.68千字
  • 约 70页
  • 2020-11-19 发布于浙江
  • 举报
清华大学c--课件第3章;函数的定义;函数的定义;函数的调用;例3-1编写一个求x的n次方的函数; 运行结果: 5 to the power 2 is 25;例3-2 数制转换;#include iostream using namespace std; //计算x的n次方 double power (double x, int n); int main() { int value = 0; cout Enter an 8 bit binary number ; for (int i = 7; i = 0; i--) { char ch; cin ch; if (ch == 1) value += static_castint(power(2, i)); } cout Decimal value is value endl; return 0; } double power (double x, int n) { double val = 1.0; while (n--) val *= x; return val; };例3-3编写程序求π的值;#include iostream using namespace std; double arctan(double x) { double sqr = x *

文档评论(0)

1亿VIP精品文档

相关文档