下面程序的功能是输入一个数字(范围在0~6,若不在此范围内则显示输入错),输入对应的星期单词(Sunday,Monday,Tuesday,…,Saturday)。请填空使程序完整、正确。 #include using namespace std;void main(){int i; char *week[10] ={"Sunday","Monday","Tuesday","Wednesday Thursday","Friday", "Saturday"};cin >> i;if ((1____)];elsecout << "输出错误!\n";}
查看答案
下面函数的功能是用递归法将一个整数的各位数字分离,然后按逆序存放在一个字符数组中。如将123存放成"321 "。请填空使程序完整、正确。 void convert (char *a, int n) { int i; if ( (i=n/10) !=0) convert ( (1____); }
以下函数fun的功能是返回str所指字符串中以形参c中字符开头的后续字符的串的首地址。例如,str所指字符串为"Hello!",c中的字符为e,则函数返回字符中" ello! " 的首地址。若str所指字符串为空串或不包含c中的字符,则函数返回NULL。请填空使程序完整、正确。 char *fun(char *str, char c){int n = 0; char *p = str;if (p != NULL)while (*p != c&&*p != '\0')(1____);}
下面函数的功能是根据公式s=l-1/3+1/5-1/7+...+(-1n )/(2*n+1)计算s,计算结果通过形参指针sn传回。n通过形参传入,n的值大于等于0。请填空使程序完整、正确。void fun(float *sn,int n){ float s=0.0,w,f=-1.0;int i=0;for(i=0;i<=n;i++){f=(1____)=s;}
下面函数的功能是将两个字符串s1和s2连接起来。请填空使程序完整、正确。 void conj (char *s1,char *s2) { char *p=sl; while (*s1) (1____); s1++, s2++; }*s1=' \0'; }