C 计算温度项目,产生误差
这里有点C语言的麻烦。不管怎样,我已经在这个项目上工作了一段时间,在VisualStudio2010中编译它时,它产生了很多错误 它说当使用浮动时可能会丢失数据请记住整个项目都是建立在浮动之上的 此外,这就是我所犯的错误 1> ---生成已启动:项目:项目,配置:调试Win32--- 1> 项目c 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c44:警告C4996:“scanf”:此函数或变量可能不安全。考虑使用SncFis代替。要禁用弃用,请使用_CRT\u SECURE\u NO\u警告。有关详细信息,请参阅联机帮助。 1> c:\program files x86\microsoft visual studio 10.0\vc\include\stdio.h304:请参阅“scanf”的声明 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c55:警告C4013:“系统”未定义;假设外部返回int 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c29:警告C4101:“y”:未引用的局部变量 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c77:警告C4244:“=”:从“int”转换为“float”,可能会丢失数据 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c78:警告C4244:“=”:从“int”转换为“float”,可能会丢失数据 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c79:警告C4244:“=”:从“int”转换为“float”,可能会丢失数据 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c80:警告C4244:“=”:从“int”转换为“float”,可能会丢失数据 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c81:er 这是我的密码C 计算温度项目,产生误差,c,visual-studio-2010,visual-studio,visual-studio-2012,project,C,Visual Studio 2010,Visual Studio,Visual Studio 2012,Project,这里有点C语言的麻烦。不管怎样,我已经在这个项目上工作了一段时间,在VisualStudio2010中编译它时,它产生了很多错误 它说当使用浮动时可能会丢失数据请记住整个项目都是建立在浮动之上的 此外,这就是我所犯的错误 1> ---生成已启动:项目:项目,配置:调试Win32--- 1> 项目c 1> c:\users\suliman\documents\visual studio 2010\projects\project\project\project.c44:警告C4996:“scanf
#include <stdio.h>
void table();
float inspect();
float calculation(float x1, float x2, float x3);
float SLOPE();
//time, **t is for time**
int t1=0;
int t2 = 1;
int t3 = 2;
int t4 = 3;
int t5 = 4;
int t6 = 5;
//Tempreture **h is for heat**
int h1=20;
int h2=36;
int h3=61;
int h4=68;
int h5=77;
int h6=110;
int n=6;
int main()
{
float m;
float b;
float y,x;
float res2;
float res1;
float result;
table();
m=SLOPE();
b=inspect();
res1=calculation(b,m,1.5);
printf("The temperture int TIME 1.5=%f\n",result);
res2=calculation(b,m,4.5);
printf("The temperture int time at 4.5 = %f\n", result);
printf("Please enter the time values you require");
scanf("%f",&x);
if (x>0)
{
result=calculation(b,m,x);
printf("The temperture value is: %f",result);
}
else
printf("**ERROR**");
system("pause");
return 0;
}
void table()
{
printf("Time Tempreture\n");
printf("%d %d\n",t1,h1);
printf("%d %d\n",t2,h2);
printf("%d %d\n",t3,h3);
printf("%d %d\n",t4,h4);
printf("%d %d\n",t5,h5);
printf("%d %d\n",t6,h6);
}
float inspect()
{
float result;
float e1,e2,e3,e4;
e1=t1+t2+t3+t4+t5+t6;
e2=t1*h1+t2*h2+t3*h3+t4*h4+t5*h5+t6*h6;
e3=h1+h2+h3+h4+h5+h6;
e4=t1*t1+t2*t2+t3*t3+t4*t4+t5*t5+t6*t6;
result=(e1*e3-n*e2)(e1*e1-n*e4);
return result;
}
float calculation(float x1,float x2, float x3)
{
float y;
y=x2*x3+x1;
return y;
}
仔细查看后,我正在打印结果变量,该变量甚至没有初始化,而我需要打印res1和res2Sulaiman AlOmar结果中存在编译错误=e1*e3-ne2e1*e1-ne4;inspect函数行。有关int-to-float转换警告,请参阅。然后如何修复错误?在第81行,您忘记在b/w大括号中使用*结果=e1*e3-ne2e1*e1-ne4,并且您没有在代码中定义斜率函数。其余的事情只是警告。仔细观察后,我打印的结果变量甚至还没有初始化,而我需要打印res1和res2。