我正在学习 C 编程并编写了一个简单的程序来学习 C 中的函数。我在这里使用了两个函数,虽然第一个有效但第二个无效!
这是简单的代码:
#include<stdio.h>
void main() {
int a,b,c,sum;
printf("Input your numbers one by one:\n");
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
printf("You have put %d, %d, %d\n\n", a, b, c);
max (a,b,c);
min (a,b,c);
}
void max (int a, int b, int c) {
int sum;
a=sum;
if(sum>b)
sum=b;
if(sum>c)
sum=c;
}
void min (int f, int g, int h) {
int sum;
sum=f;
if(sum<g)
sum=g;
if(sum<h)
sum=h;
printf("The lowest value is:%d\n\n\n",sum);
}
谁能告诉我为什么会发生这种情况以及解决方案?