本人通过实验发现:scanf函数不能输出含有空格符的字符串,而gets函数能输出含空格符的字符串。
下面是本人自己写的字符串复制函数Mystrcpy():
void MyStrcopy(char* str1,char* str2)
{
int i=0,j=0;
while(1)
{
while(str2[j]!='/0')
{
str1[i]=str2[j];
j++;
i++;
}
str1[i]='/0';
break;
}
}
本人还用递归方法解决了猴子吃桃问题:
#include<stdio.h>
int f(int i)
{
if(i==1)
return 1;
else
{
return 2*f(i-1)+2;
}
}
int main()
{
printf("%d/n",f(10));
return 0;
}
猴子吃桃问题见课本P129