7-4 平面向量加法 (15 分)

137 阅读1分钟
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	double x1 = 0;
	double y1 = 0;
	double x2 = 0;
	double y2 = 0;
	cin >> x1 >> y1 >> x2 >> y2;
	double x = x1+x2;
	double y = y1+y2;
    if(x >= -0.05 && x<0)//一定注意保留1位小数时输出-0.0的情况 
    {
        x = 0;
    }
    if(y >= -0.05 && y<0)
    {
        y = 0;
    }
    printf("(%.1lf, %.1lf)", x, y);


}