實(shí)用C++面試筆試題目
定義一結(jié)構(gòu)體變量,用其表示點(diǎn)坐標(biāo),并輸入兩點(diǎn)坐標(biāo),求兩點(diǎn)之間的距離
解:#include
#include
struct point
{
float x;
float y;
};
main()
{ float dis;
struct point pt1,pt2;
printf(“input point1.x:”);
scanf(“%f”,&pt1.x);
printf(“input point1.y:”);
scanf(“%f”,&pt1.y);
printf(“input point2.x:”);
scanf(“%f”,&pt2.x);
printf(“input point2.y:”);
scanf(“%f”,&pt2.y);
dis=sqrt((pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y));
printf(“The distance of the two points is:%f”,dis);
}
【實(shí)用C++面試筆試題目】相關(guān)文章:
C++面試筆試題目12-12
經(jīng)典c++面試筆試題目12-11
C C++面試筆試題目集錦11-14
C++筆試題目分享11-22
經(jīng)典c++面試筆試題目22題12-11
北承筆試題目(C++)11-23
C++、數(shù)據(jù)結(jié)構(gòu)筆試題目11-14
C/C++面試題目12-12
面試會(huì)計(jì)的筆試題目11-23