当前位置:网站首页>Plane vector addition
Plane vector addition
2022-07-03 14:33:00 【Study hard 867】
This question requires the preparation of procedures , Calculate the sum of two two-dimensional plane vectors .
Input format :
Type in a line and press “x1 y1 x2 y2” The format gives two two two-dimensional plane vectors v1=(x1,y1) and v2=(x2,y2) Components of .
Output format :
In a row, press (x, y)
Format output and vector , The coordinates are output to one digit after the decimal point ( Note that... Cannot be output −0.0).
sample input :
3.5 -2.7 -13.9 8.7
sample output :
(-10.4, 6.0)
Code :
#include <stdio.h>
#include <math.h>
int main()
{
double x1,y1,x2,y2;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
double x,y;
x=x1+x2;
y=y1+y2;
// When x,y The absolute value of is less than 0.05 when , Unqualified “ No output -0.0”, here x,y The value of should be set to 0.0
if(fabs(x)<0.05)
{
x = 0.0;
}
if(fabs(y)<0.05)
{
y = 0.0;
}
printf("(%.1f, %.1f)",x,y);
return 0;
}
边栏推荐
猜你喜欢
tonybot 人形机器人 红外遥控玩法 0630
tonybot 人形机器人 定距移动 代码编写玩法
puzzle(016.4)多米诺效应
puzzle(016.3)千丝万缕
Understand the application scenario and implementation mechanism of differential segment
NPM install is stuck with various strange errors of node NPY
编程语言:类型系统的本质
Tonybot humanoid robot infrared remote control play 0630
7-18 finding the single root of polynomial by dichotomy
tonybot 人形机器人 首次开机 0630
随机推荐
Showmebug entered Tencent conference, opening the era of professional technical interview
Mongodb index
7-23 currency conversion (using array conversion)
Paper sharing: generating playful palettes from images
x86汇编语言-从实模式到保护模式 笔记
7-14 sum integer segments (C language)
Thread. Sleep and timeunit SECONDS. The difference between sleep
C library function - qsort()
Exercise 10-2 recursive factorial sum
分布式事务(Seata) 四大模式详解
Creation of data table of Doris' learning notes
7-24 reduction of the simplest fraction (rolling Division)
洛谷P5194 [USACO05DEC]Scales S 题解
常见问题之PHP——ldap_add(): Add: Undefined attribute type in
基因家族特征分析 - 染色体定位分析
Protobuf and grpc
SSH访问控制,多次失败登录即封掉IP,防止暴力破解
6-9 statistics of single digits (15 points)
天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库
7-11 calculation of residential water charges by sections