实用C++面试笔试题目
定义一结构体变量,用其表示点坐标,并输入两点坐标,求两点之间的距离
解:#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);
}
【实用C++面试笔试题目】相关文章:
C++面试笔试题目12-12
经典c++面试笔试题目12-11
C C++面试笔试题目集锦11-14
C++笔试题目分享11-22
经典c++面试笔试题目22题12-11
北承笔试题目(C++)11-23
C++、数据结构笔试题目11-14
C/C++面试题目12-12
面试会计的笔试题目11-23