error LNK1120: 1 个无法解析的外部命令 错误 1 error LNK2019: 无法解析的外部符号 5
#include<stdio.h>intinput(float*array_number,unsignedn);intaverage(float*array_number...
#include <stdio.h>
int input(float *array_number, unsigned n);
int average(float *array_number, unsigned n, float *aver);
int maxmin(float *array_number, unsigned n, float *max, float *min);
int main(void)
{
float date[10];
float aver = 0.0f, max = 0.0f, min = 0.0f;
input(date, 10);
average(date, 10, &aver);
maxmin(date, 10, &max, &min);
printf("aver=%f", aver);
printf("max=%f,min=%f", max, min);
return 0;
}
int input(float array_number, unsigned n)
{
printf("输入这个数组【10】:\n");
for (unsigned i = 0; i < n; ++i)
{
scanf_s("%d", array_number, 1);
}
return 0;
}
int average(float *array_number, unsigned n, float*aver)
{
float sum = 0.0f;
for (unsigned i = 0; i < n; ++i)
{
sum += *array_number;
}
*aver = (float)sum / 10;
return 0;
}
int maxmin(float *array_number, unsigned n, float *max, float *min)
{
for (unsigned i = 0; i<n; ++i)
{
if (*max<*(array_number + i))
{
*max = *(array_number + i);
}
if (*min>*(array_number + i))
{
*min = *(array_number + i);
}
}
return 0;
}
这个程序哪部分错了,跪求!!!!!!! 展开
int input(float *array_number, unsigned n);
int average(float *array_number, unsigned n, float *aver);
int maxmin(float *array_number, unsigned n, float *max, float *min);
int main(void)
{
float date[10];
float aver = 0.0f, max = 0.0f, min = 0.0f;
input(date, 10);
average(date, 10, &aver);
maxmin(date, 10, &max, &min);
printf("aver=%f", aver);
printf("max=%f,min=%f", max, min);
return 0;
}
int input(float array_number, unsigned n)
{
printf("输入这个数组【10】:\n");
for (unsigned i = 0; i < n; ++i)
{
scanf_s("%d", array_number, 1);
}
return 0;
}
int average(float *array_number, unsigned n, float*aver)
{
float sum = 0.0f;
for (unsigned i = 0; i < n; ++i)
{
sum += *array_number;
}
*aver = (float)sum / 10;
return 0;
}
int maxmin(float *array_number, unsigned n, float *max, float *min)
{
for (unsigned i = 0; i<n; ++i)
{
if (*max<*(array_number + i))
{
*max = *(array_number + i);
}
if (*min>*(array_number + i))
{
*min = *(array_number + i);
}
}
return 0;
}
这个程序哪部分错了,跪求!!!!!!! 展开
1个回答
展开全部
重新给你调整了一下,运行通过
#include <stdio.h>
int maxmin(float *array_number, unsigned n, float *max, float *min)
{
unsigned i = 0;
for (i = 0; i<n; ++i)
{
if (*max<*(array_number + i))
{
*max = *(array_number + i);
}
if (*min>*(array_number + i))
{
*min = *(array_number + i);
}
}
return 0;
}
int input(float* array_number, unsigned n)
{
printf("输入这个数组【10】:\n");
unsigned i = 0;
for (i = 0; i < n; ++i)
{
int d;
scanf("%d", &d);
*(array_number+i) = d;
}
return 0;
}
int average(float *array_number, unsigned n, float*aver)
{
float sum = 0.0f;
unsigned i = 0;
for (i = 0; i < n; ++i)
{
sum += *(array_number+i);
}
*aver = (float)sum / 10;
return 0;
}
int main(void)
{
float date[10] = {01};
float aver = 0.0f, max = -100000.0f, min = 100000.0f;
input(date, 10);
average(date, 10, &aver);
maxmin(date, 10, &max, &min);
printf("aver=%f", aver);
printf("max=%f,min=%f", max, min);
return 0;
}
#include <stdio.h>
int maxmin(float *array_number, unsigned n, float *max, float *min)
{
unsigned i = 0;
for (i = 0; i<n; ++i)
{
if (*max<*(array_number + i))
{
*max = *(array_number + i);
}
if (*min>*(array_number + i))
{
*min = *(array_number + i);
}
}
return 0;
}
int input(float* array_number, unsigned n)
{
printf("输入这个数组【10】:\n");
unsigned i = 0;
for (i = 0; i < n; ++i)
{
int d;
scanf("%d", &d);
*(array_number+i) = d;
}
return 0;
}
int average(float *array_number, unsigned n, float*aver)
{
float sum = 0.0f;
unsigned i = 0;
for (i = 0; i < n; ++i)
{
sum += *(array_number+i);
}
*aver = (float)sum / 10;
return 0;
}
int main(void)
{
float date[10] = {01};
float aver = 0.0f, max = -100000.0f, min = 100000.0f;
input(date, 10);
average(date, 10, &aver);
maxmin(date, 10, &max, &min);
printf("aver=%f", aver);
printf("max=%f,min=%f", max, min);
return 0;
}
追问
能给个理由吗,为甚吗这么做的话,link错误消除了
还有你可能没有认真看程序的功能,这么做很多问题
追答
嗯。。。因为你原来的程序报错太多,没法一一分辨是为什么,于是就把你主要的几个函数提了出来,再一一调试通过
实测录入10个数字,结果也是对的(主要是你一开始设定max=0,min=0,这样的话如果我不输入负数,min就永远是0;而如果我只输入负数,max就永远是0,因此把他们都先设了一个很大的正负数)
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询