当前位置:网站首页>1051 复数乘法 (15 分)
1051 复数乘法 (15 分)
2022-08-11 06:46:00 【呆比特】
题目要求:
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//輸入
Scanner scanner = new Scanner(System.in);
double r1 = scanner.nextDouble();
double p1 = scanner.nextDouble();
double r2 = scanner.nextDouble();
double p2 = scanner.nextDouble();
double a = r1 * Math.cos(p1);
double b = r1 * Math.sin(p1);
double c = r2 * Math.cos(p2);
double d = r2 * Math.sin(p2);
//(a+bi)*(c+di) = ac + adi +bci -bd = (ac-bd) + (ad+bc)i
double s = a * c - b * d;
String sb = "-0.00".equals(String.format("%.2f",s)) ? "0.00" : String.format("%.2f",s);
double x = a * d + b * c;
String xb = x >= 0 ? (String.format("+%.2fi", x)) : (String.format("%.2fi", x));
if ("-0.00i".equals(xb)) {
xb = "+0.00i";
}
System.out.println(sb + xb);
}
}
结果:
边栏推荐
猜你喜欢
下一代 无线局域网--强健性
囍楽云任务源码
Pinduoduo API interface (attach my available API)
A used in the study of EEG ultra scanning analysis process
easyrecovery15数据恢复软件收费吗?功能强大吗?
Attitude solution - gyroscope + Euler method
jar服务导致cpu飙升问题-带解决方法
NFT 的价值从何而来
Tensorflow中使用tf.argmax返回张量沿指定维度最大值的索引
radix-4 FFT principle and C language code implementation
随机推荐
Douyin API interface
【软件测试】(北京)字节跳动科技有限公司二面笔试题
Daily SQL - find each of the students school gpa minimum (window)
CIKM 2022 AnalytiCup Competition: 联邦异质任务学习
PIXHAWK飞控使用RTK
mysql视图与索引
ssh服务攻防与加固
TF中的One-hot
MindManager2022全新正式免费思维导图更新
Daily sql-statistics of the number of professionals (including the number of professionals is 0)
从 dpdk-20.11 移植 intel E810 百 G 网卡 pmd 驱动到 dpdk-16.04 中
tf.cast(),reduce_min(),reduce_max()
【sdx62】XBL设置共享内存变量,然后内核层获取变量实现
EasyPlayer针对H.265视频不自动播放设置下,loading状态无法消失的解决办法
伦敦银规则有哪些?
opencv实现数据增强(图片+标签)平移,翻转,缩放,旋转
求职简历这样写,轻松搞定面试官
oracle19c不支持实时同步参数,请教一下大佬们有什么好的解决办法吗?
Depth (relay supervision)
Redis + lua implements distributed interface current limiting implementation scheme