为什么编译时出现这个错误如何解决函数的隐式声明?
why this error coming when compiling how to solve implicit declaration of function?
#include<stdio.h>
#include<math.h>
float val [4][2],a[4];
int j,i,y;
float cordianation_entry() {
printf("enter your cordianation-");
scanf("%f,%f",&val[0][0],&val[0][1]);
for(j=1;j<4;j++) {
printf("enter station %d coordination-",j);
scanf("%f,%f",&val[j][0],&val[j][1]);
}
}
float results_analysis() {
for(i=1;i<4;i++) {
a[i] = (pow((val[i][0]-val[0][0]),2)) + (pow((val[i][1]-val[0][1]),2));
a[i]=sqrt(a[i]);
printf("\n*distance to station %d is %f\n",i,a[i]);
if(a[i]<100)
printf("\tDistance is Low");
else if(a[i]<1000 && a[i]>=100)
printf("\tDistance is Moderate");
else
printf("\tDistance is High");
}
编译器不读取这个最小函数
浮动最小值(){
if(a[1]<a[2]&&a[1]<a[3])
printf("station 1 is the nearest");
else if(a[2]<a[3]&&a[2]<a[1])
printf("station 2 is the nearest");
else if(a[3]<a[1]&&a[3]<a[2])
printf("station 2 is the nearest");
}
}
编译器没有检测到最小函数如何解决
编译时显示错误消息 implicit decleration of function minimum
void main() {
cordianation_entry();
results_analysis();
minimum();
}
问题是您没有正确使用 {}
括号。特别是这个功能:
float results_analysis() {
for(i=1;i<4;i++) {
a[i] = (pow((val[i][0]-val[0][0]),2)) + (pow((val[i][1]-val[0][1]),2));
a[i]=sqrt(a[i]);
printf("\n*distance to station %d is %f\n",i,a[i]);
if(a[i]<100)
printf("\tDistance is Low");
else if(a[i]<1000 && a[i]>=100)
printf("\tDistance is Moderate");
else
printf("\tDistance is High");
}
} // <--- Missing in your code
还有一个 }
不应该出现的括号:
float minimum() {
if(a[1]<a[2]&&a[1]<a[3])
printf("station 1 is the nearest");
else if(a[2]<a[3]&&a[2]<a[1])
printf("station 2 is the nearest");
else if(a[3]<a[1]&&a[3]<a[2])
printf("station 2 is the nearest");
}
// } <--- Wrong
#include<stdio.h>
#include<math.h>
float val [4][2],a[4];
int j,i,y;
float cordianation_entry() {
printf("enter your cordianation-");
scanf("%f,%f",&val[0][0],&val[0][1]);
for(j=1;j<4;j++) {
printf("enter station %d coordination-",j);
scanf("%f,%f",&val[j][0],&val[j][1]);
}
}
float results_analysis() {
for(i=1;i<4;i++) {
a[i] = (pow((val[i][0]-val[0][0]),2)) + (pow((val[i][1]-val[0][1]),2));
a[i]=sqrt(a[i]);
printf("\n*distance to station %d is %f\n",i,a[i]);
if(a[i]<100)
printf("\tDistance is Low");
else if(a[i]<1000 && a[i]>=100)
printf("\tDistance is Moderate");
else
printf("\tDistance is High");
}
编译器不读取这个最小函数
浮动最小值(){
if(a[1]<a[2]&&a[1]<a[3])
printf("station 1 is the nearest");
else if(a[2]<a[3]&&a[2]<a[1])
printf("station 2 is the nearest");
else if(a[3]<a[1]&&a[3]<a[2])
printf("station 2 is the nearest");
}
}
编译器没有检测到最小函数如何解决
编译时显示错误消息 implicit decleration of function minimum
void main() {
cordianation_entry();
results_analysis();
minimum();
}
问题是您没有正确使用 {}
括号。特别是这个功能:
float results_analysis() {
for(i=1;i<4;i++) {
a[i] = (pow((val[i][0]-val[0][0]),2)) + (pow((val[i][1]-val[0][1]),2));
a[i]=sqrt(a[i]);
printf("\n*distance to station %d is %f\n",i,a[i]);
if(a[i]<100)
printf("\tDistance is Low");
else if(a[i]<1000 && a[i]>=100)
printf("\tDistance is Moderate");
else
printf("\tDistance is High");
}
} // <--- Missing in your code
还有一个 }
不应该出现的括号:
float minimum() {
if(a[1]<a[2]&&a[1]<a[3])
printf("station 1 is the nearest");
else if(a[2]<a[3]&&a[2]<a[1])
printf("station 2 is the nearest");
else if(a[3]<a[1]&&a[3]<a[2])
printf("station 2 is the nearest");
}
// } <--- Wrong