当前位置:网站首页>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;
}
边栏推荐
- Puzzle (016.3) is inextricably linked
- puzzle(016.4)多米诺效应
- Solr series of full-text search engines - basic principles of full-text search
- Exercise 10-6 recursively find Fabonacci sequence
- Understand the application scenario and implementation mechanism of differential segment
- 7-6 mixed type data format input
- 添加Zabbix计算类型项目Calculated items
- 7-11 calculation of residential water charges by sections
- 7-18 finding the single root of polynomial by dichotomy
- 7-28 monkeys choose King (Joseph problem)
猜你喜欢
pyQt界面制作(登录+跳转页面)
Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
retrofit
Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
7-11 calculation of residential water charges by sections
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
How to query the baby category of tmall on Taobao
Four data flows and cases of grpc
Tonybot Humanoïde Robot Infrared Remote play 0630
随机推荐
Special research report on the market of lithium battery electrolyte industry in China (2022 Edition)
tonybot 人形机器人 查看端口并对应端口 0701
7-28 monkeys choose King (Joseph problem)
Paper sharing: generating playful palettes from images
String substitution
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
7-15 calculation of PI
6-9 statistics of single digits (15 points)
【7.3】146. LRU缓存机制
使用并行可微模拟加速策略学习
Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
Tonybot humanoid robot infrared remote control play 0630
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
556. 下一个更大元素 III
Adc128s022 ADC Verilog design and Implementation
Although not necessarily the best, it must be the hardest!
关于敏捷的一些概念
Etcd cluster permission management and account password usage
Niuke: crossing the river
npm install卡住与node-npy的各种奇怪报错