两道c语言题 帮忙回答一下吧

来源:百度知道 编辑:UC知道 时间:2024/05/21 00:47:59
1.编写程序,计算并输出1!+2!+…+10!的结果

2.编写自定义函数scopy(),要求实现字符串拷贝功能(注:不得使用库函数strcpy()实现字符串的拷贝)。主程序已经给出,请根据已有内容编写自定义函数scopy()。
说明:scopy函数有两个形参,功能是把第二个参数的内容拷贝到第一个参数中。
#include <stdio.h>
void scopy(char s1[], char s2[])
{

}
void main( )
{
char b[20]=”hello”,a[20];
scopy(a,b);
printf(“%s”,a);
}

第一个
int fun(int n)
{
if(n==0||n==1)
return 1;
return n*fun(n-1);
}
main()
{
int sum=0;
for(int i=1;i<=10;i++)
sum+=fun(i);
printf("%d\n",sum);
}
第二个
#include <stdio.h>
void scopy(char s1[], char s2[])
{
while (*s2!='\0')
{
*s1=*s2;
s1++;
s2++;
}
*s1='\0';

}
void main( )
{
char b[20]="hello",a[20];
scopy(a,b);
printf("%s",a);
}

1.
#include<stdio.h>

int main()
{
int i;
long temp = 1L;
long sum = 0;
for(i = 1; i <= 10; i++)
{
temp *= i;
sum += temp;
}
printf("Result: %ld\n", sum);
return 0;
}

2.
#include <stdio.h>

void scopy(char s1[], char s2[])
{
while(*s2 != '&#