nbsp; // (1)
return f(____________) + f(___________); // (2)、 (3)
}
int main()
{
int m, n;
cin>>n>>m;
cout<<f(n, m)<<endl;
return 0;
}
29.删除字符串s中指定的字符ch。编程实现该函数的定义,使得程序运行后,输出:Iamaboy!
#include <iostream>
using namespace std;
void fun(char *s,char ch)
{
char *p=s;
while (__________) // (1)
{
if (*s!=ch)
{ *p=*s; __________; } // (2)
s++;
}
__________; // (3)
}
int main()
{
char str[]="I am a boy!";
func(str,' ');
cout<<str<<endl;
return 0;
}
30.函数fun的功能是:根据所给的年、月、日,计算出该日是这一年的第几天,并作为函数值返回。例如,函数fun(2016,10,1)的返回值为275,表示2016年10月1日是该年的第275天。请填空将函数补充完整。
int fun(int year,int month,int day)
{
int table[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int s=0,i;
for (i=1;i<__________; i++) // (1)
s=s+__________; // (2)
s=s+day;
if ((________________________________________) && month>2) // (3)
s=s+1;
return s;
}
31.函数int fun(int x)的功能是求正整数x的逆序数。例如,函数fun(1234)的返回值为4321。
int fun(int x)
{
int sum = 0;
while (x != 0)
{
______________________; // (1)
______________________; // (2)
}
_____________________________; // (3)
}
32.把一个整数的每个数位都平方后求和,又得到一个整数,我们称这个整数为位平方和。对新得到的整数仍然可以继续这一运算过程。比如,给定整数为4,则一系列的运算结果为:16,37,58,89,....。已知一个整数x,求第n步的运算结果。
#include <iostream.h>
int digitSum(int x)
{
int s=0,d;
while (__________________) // (1)
{ __________________; // (2)