C语言,求问前三题的程序,最好能是程序和解释,求大神,c需要刚刚学,不怎么会啊…
答案:1 悬赏:20 手机版
解决时间 2021-02-06 04:09
- 提问者网友:愿为果
- 2021-02-05 03:17
C语言,求问前三题的程序,最好能是程序和解释,求大神,c需要刚刚学,不怎么会啊…
最佳答案
- 五星知识达人网友:大漠
- 2021-02-05 04:29
#include
#include
#include
#include
double fun1(double a, double b)
{
return sqrt(a)+sqrt(b);
}
int fun2(int num)
{
int result = 1;
int mod;
while(num)
{
mod = num%10;
result *= mod;
num = num/10;
}
return result;
}
void fun3(int *a, int *b)
{
*a = *a + *b;
*b = *a - *b;
*a = *a - *b;
}
int main()
{
int a=5, b=3;
printf("fun1(12, 20): %lf
", fun1(12, 20));
printf("fun2(252): %d
", fun2(252));
printf("fun2(202): %d
", fun2(202));
printf("before exchange: a=%d, b=%d
", a, b);
fun3(&a, &b);
printf("after exchange: a=%d, b=%d
", a, b);
return 0;
}追问问一下那4个include 后面的是啥意思…就认识stdio math谢谢了,能不能单独的把第一道题打出来一下,一直没搞明白,之前回答的没看懂追答
#include
#include
double fun1(double a, double b)
{
return sqrt(a)+sqrt(b);
}
int main()
{
int a=5, b=3;
double result;
result = fun1(12, 20)
printf("fun1(12, 20): %lf
", result);
return 0;
}
#include
#include
#include
double fun1(double a, double b)
{
return sqrt(a)+sqrt(b);
}
int fun2(int num)
{
int result = 1;
int mod;
while(num)
{
mod = num%10;
result *= mod;
num = num/10;
}
return result;
}
void fun3(int *a, int *b)
{
*a = *a + *b;
*b = *a - *b;
*a = *a - *b;
}
int main()
{
int a=5, b=3;
printf("fun1(12, 20): %lf
", fun1(12, 20));
printf("fun2(252): %d
", fun2(252));
printf("fun2(202): %d
", fun2(202));
printf("before exchange: a=%d, b=%d
", a, b);
fun3(&a, &b);
printf("after exchange: a=%d, b=%d
", a, b);
return 0;
}追问问一下那4个include 后面的是啥意思…就认识stdio math谢谢了,能不能单独的把第一道题打出来一下,一直没搞明白,之前回答的没看懂追答
#include
#include
double fun1(double a, double b)
{
return sqrt(a)+sqrt(b);
}
int main()
{
int a=5, b=3;
double result;
result = fun1(12, 20)
printf("fun1(12, 20): %lf
", result);
return 0;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯