问题及代码 :
/*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称 :
*作 者 : 刘云
*完成日期 : 2016年3月19号
*版 本 号 : v1.0
*
*问题描述 : 递归问题
*输入描述 : 无
*程序输出 : fun函数即递归函数fibnacci函数
/*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称 :
*作 者 : 刘云
*完成日期 : 2016年3月19号
*版 本 号 : v1.0
*
*问题描述 : 递归问题
*输入描述 : 无
*程序输出 : fun函数即递归函数fibnacci函数
*/
#include <iostream>
using namespace std;
const double pi=3.1415926;
float area(float r=6.5);//指定r的默认值为6.5
float volume(float h,float r=6.5); //指定r的默认值为6.5
int main( )
{
cout<<area()<<endl; //相当于area(6.5);
cout<<area(7.5)<<endl; //形参得到的值为7.5,而不是6.5
cout<<volume(45.6)<<endl; //相当于volume(45.6,6.5)
cout<<volume(34.2,10.4)<<endl; //h的值为34.2,r的值为10.4
return 0;
}
float area(float r)
{
return pi*r*r;
}
float volume(float h,float r)
{
return pi*r*r*h;
}