关于“sqrt”的问题 [英] a problem about "sqrt"
问题描述
为什么打印错误的结果?我找不到错误的地方。
#include< stdio.h>
#include< math.h>
双倍距离(双倍a,双倍b,双倍c,双倍d);
int main()
{
double x1,y1,x2,y2;
双倍结果;
printf("输入四个数字:");
scanf("%f%f%f%f"& x1,& y1,& x2,& y2);
result = distance( x1,y1,x2,y2);
printf(" distancd是%。1f",结果);
返回0 ;
}
双倍距离(双倍,双倍,双倍,双倍)
{
return sqrt((ac)*(ac)+(bd)*(bd));
}
li**********@163.com 写道:< br>
>
为什么打印出错误的结果?我找不到错误的地方。
#include< stdio.h>
#include< math.h>
双倍距离(双倍a,双倍b,双倍c,双倍d);
int main()
{
double x1,y1,x2,y2;
双倍结果;
printf("输入四个数字:");
scanf("%f%f%f%f"& x1,& y1,& x2,& y2);
在这里打印x1,x2,y1和y2的值。
他们是,你期望什么?
result = distance(x1,y1,x2,y2);
printf(" distancd is%.1f" ;,结果);
返回0;
}
双倍距离(双a,双b,双c,双d)
{
或者,在此打印a,b,c和d的值。例如:
std :: cout<< a<< " " << b<< " " << c<< " " << d<< " \ n";
返回sqrt((ac)*(ac)+(bd)*(bd));
>
}
Best
Kai-Uwe Bux
>
< li ********** @ 163.comwrote:
为什么打印错误的结果?我找不到错误的地方。
#include< stdio.h>
#include< math.h>
双倍距离(双倍a,双倍b,双倍c,双倍d);
int main()
{
double x1,y1,x2,y2;
双倍结果;
printf("输入四个数字:");
scanf("%f%f%f%f"& x1,& y1,& x2,& y2);
说谎到I / O例程的处罚通常很严重。
>
result = distance(x1,y1,x2,y2);
printf(" distancd is%.1f",result);
返回0;
}
双倍距离(双倍a,双倍b,双倍c,双倍d)
{
返回sqrt((ac)*(ac)+(bd)*(bd));
}
James Kanze写道:
double x1;
double y1;
双x2;
双y2;
一个风格问题,但它真的*必须如此冗长吗?
老实说我不认为这是任何不太清楚(如果有的话,它是
相反):
double x1,y1,x2,y2;
why it print wrong result? I can''t find the wrong place.
#include<stdio.h>
#include<math.h>
double distance(double a ,double b,double c,double d);
int main()
{
double x1,y1,x2,y2;
double result;
printf("Enter four numbers:");
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
result=distance(x1,y1,x2,y2);
printf("The distancd is %.1f",result);
return 0;
}
double distance(double a,double b,double c,double d)
{
return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
li**********@163.com wrote:
>
why it print wrong result? I can''t find the wrong place.
#include<stdio.h>
#include<math.h>
double distance(double a ,double b,double c,double d);
int main()
{
double x1,y1,x2,y2;
double result;
printf("Enter four numbers:");
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);Print the values of x1, x2, y1, and y2 here.
Are they, what you expect?
result=distance(x1,y1,x2,y2);
printf("The distancd is %.1f",result);
return 0;
}
double distance(double a,double b,double c,double d)
{Or, print the values of a, b, c, and d here. E.g.:
std::cout << a << " " << b << " " << c << " " << d << "\n";
return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
Best
Kai-Uwe Bux
<li**********@163.comwrote:
why it print wrong result? I can''t find the wrong place.
#include<stdio.h>
#include<math.h>
double distance(double a ,double b,double c,double d);
int main()
{
double x1,y1,x2,y2;
double result;
printf("Enter four numbers:");
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);The penalties for lying to the I/O routines are often severe.
>
result=distance(x1,y1,x2,y2);
printf("The distancd is %.1f",result);
return 0;
}
double distance(double a,double b,double c,double d)
{
return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
James Kanze wrote:double x1 ;
double y1 ;
double x2 ;
double y2 ;A question of style, but is it *really* necessary to be so verbose?
I honestly don''t think this is any less clear (if anything, it''s the
contrary):
double x1, y1, x2, y2;
这篇关于关于“sqrt”的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!