本人实习,写了一个处理测量数据的程序,有一个步骤出了点错误,谁能告诉我怎么回事啊!!!!!!!
最近因为测量实习,要处理很多数据,天天按计算器很烦,我就写了一个处理角度的算法,但是在数组函数调用这一块老是出错,谁能帮我解决一下啊,我急着需要用啊,我先把代码贴出来,cpp格式,vc6.0下编译,程序代码:
#include "stdio.h" #include "math.h" #include "windows.h" #define n 3 void jiafa(int yi[n],int er[n]) { FILE *out; int t[n],m; out=fopen("out.txt","w"); for(m=0;m<3;m++) { t[m]=yi[m]+er[m]; if(t[m]>=60) { if(m==2) { t[m]++; } else { t[m+1]++; } } } for(m=2;m>=0;m--) { fprintf(out,"%d\t",t[m]); } fprintf(out,"\n"); fclose(out); } void jianfa(int yi[n],int er[n]) { FILE *out; int t[n],m; out=fopen("out.txt","w"); for(m=0;m<3;m++) { if(yi[m]<er[m]) { yi[m]=yi[m]+60; yi[m+1]--; } else { t[m]=yi[m]-er[m]; } } for(m=2;m>=0;m--) { fprintf(out,"%d\t",t[m]); } fprintf(out,"\n"); fclose(out); } main() { FILE *data; int yi[n],er[n],m,row,i,j=2; void jiafa(int yi[n],int er[n]),jianfa(int yi[n],int er[n]); data=fopen("data.txt","r"); for(m=0;m<16;m++) { if(m%2!=0) { for(row=0;row<3;row++) { fscanf(data,"%d\t",&er[row]); } } else { for(row=0;row<3;row++) { fscanf(data,"%d\t",&yi[row]); } } jianfa(yi[3],er[3]);//////////////////////////////////////////////// } fclose(data); system("start out.txt"); }有一个错误:
#include "stdio.h"
#include "math.h"
#include "windows.h"
#define n 3
void jiafa(int yi[n],int er[n])
{
FILE *out;
int t[n],m;
out=fopen("out.txt","w");
for(m=0;m<3;m++)
{
t[m]=yi[m]+er[m];
if(t[m]>=60)
{
if(m==2)
{
t[m]++;
}
else
{
t[m+1]++;
}
}
}
for(m=2;m>=0;m--)
{
fprintf(out,"%d\t",t[m]);
}
fprintf(out,"\n");
fclose(out);
}
void jianfa(int yi[n],int er[n])
{
FILE *out;
int t[n],m;
out=fopen("out.txt","w");
for(m=0;m<3;m++)
{
if(yi[m]<er[m])
{
yi[m]=yi[m]+60;
yi[m+1]--;
}
else
{
t[m]=yi[m]-er[m];
}
}
for(m=2;m>=0;m--)
{
fprintf(out,"%d\t",t[m]);
}
fprintf(out,"\n");
fclose(out);
}
main()
{
FILE *data;
int yi[n],er[n],m,row,i,j=2;
void jiafa(int yi[n],int er[n]),jianfa(int yi[n],int er[n]);
data=fopen("data.txt","r");
for(m=0;m<16;m++)
{
if(m%2!=0)
{
for(row=0;row<3;row++)
{
fscanf(data,"%d\t",&er[row]);
}
}
else
{
for(row=0;row<3;row++)
{
fscanf(data,"%d\t",&yi[row]);
}
}
jianfa(yi[3],er[3]);////////////////////////////////////////////////
}
fclose(data);
system("start out.txt");
}
以下是错误提示代码:
--------------------Configuration: DemoCode - Win32 Debug--------------------
Compiling...
DemoCode.cpp
D:\Temp\DemoCode\DemoCode.cpp(81) : error C2664: 'jianfa' : cannot convert parameter 1 from 'int' to 'int []'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\Temp\DemoCode\DemoCode.cpp(85) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
DemoCode.exe - 1 error(s), 0 warning(s)
高手告诉我怎么回事啊?????????