当前位置:网站首页>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;
}
边栏推荐
- 7-20 print 99 formula table (format output)
- retrofit
- adc128s022 ADC verilog设计实现
- Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
- Tonybot humanoid robot infrared remote control play 0630
- 必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
- 中国锂电池电解液行业市场专项调研报告(2022版)
- Tonybot humanoid robot checks the port and corresponds to port 0701
- 分布式事务(Seata) 四大模式详解
- Table of mathematical constants by q779
猜你喜欢
Understand the application scenario and implementation mechanism of differential segment
puzzle(016.3)千丝万缕
7-15 calculation of PI
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
基因家族特征分析 - 染色体定位分析
天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
Tonybot humanoid robot checks the port and corresponds to port 0701
Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things
tonybot 人形機器人 紅外遙控玩法 0630
随机推荐
Why is this error reported when modifying records in the database
数学常数表 by q779
Luogu p4047 [jsoi2010] tribal division solution
ZABBIX saves the page blank after adding calculated items
添加Zabbix计算类型项目Calculated items
Code writing and playing method of tonybot humanoid robot at fixed distance
Puzzle (016.3) is inextricably linked
分布式事务(Seata) 四大模式详解
Find the sum of the elements of each row of the matrix
adc128s022 ADC verilog设计实现
pyQt界面制作(登录+跳转页面)
Exercise 10-3 recursive implementation of exponential functions
Thread.sleep和TimeUnit.SECONDS.sleep的区别
Exercise 10-8 recursive implementation of sequential output of integers
Too many files with unapproved license
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
Exercise 6-6 use a function to output an integer in reverse order
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
JVM garbage collector
Learn to punch in today