这里有点C语言noobie。无论哪种方式,我已经在这个项目上工作了一段时间,在Visual Studio 2010中进行编译时,它会产生错误,包含它们。
它表示使用浮动时可能会丢失数据(请记住整个项目是基于浮动的)。
此外,这是我得到的错误。
1> ------构建开始:项目:项目,配置:调试Win32 ------ 1 GT; project.c 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(44):警告C4996:'scanf':此函数或变量可能不安全。请考虑使用scanf_s。要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS。详细信息请参见在线帮助。 1 GT; c:\ program files(x86)\ microsoft visual studio 10.0 \ vc \ include \ stdio.h(304):查看'scanf'的声明 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(55):警告C4013:'system'undefined;假设extern返回int 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(29):警告C4101:'y':未引用的局部变量 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(77):警告C4244:'=':从'int'转换为'float',可能会丢失数据 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(78):警告C4244:'=':从'int'转换为'float',可能会丢失数据 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(79):警告C4244:'=':从'int'转换为'float',可能会丢失数据 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(80):警告C4244:'=':从'int'转换为'float',可能会丢失数据 1> c:\ users \ suliman \ documents \ visual studio 2010 \ projects \ project \ project \ project.c(81):呃
这是我的代码
#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;
}
答案 0 :(得分:0)
仔细观察后,我正在打印“结果”变量,该变量甚至没有初始化,而我需要打印res1&amp; RES2。 - Sulaiman AlOmar