输入两个二维平面向量V1=(x1,y1)、V2=(x2,y2)的分量,计算并输出两个向量的和向量,即V=(x1+x2,y1+y2)。
例如输入: 3.5 -2.7 -13.9 8.7 输出: -10.4 6.0
供参考:
#include <stdio.h>
struct plane {
float x;
float y;
};
int main()
{
struct plane v, v1, v2;
scanf("%f%f%f%f", &v1.x, &v1.y, &v2.x, &v2.y);
v.x = v1.x + v2.x;
v.y = v1.y + v2.y;
printf("%.1f %.1f", v.x, v.y);
return 0;
}