# Algorithm to improve the normalization of complex numbers

Source: Internet
Author: User

Algorithm improves complex normalization time limit: 1.0s memory limit: 512.0MB    The function normalize is written, the complex number is normalized, the even if complex is a+bi, and the normalized result is a/sqrt (a*a+b*b) + i*b/sqrt (a*a+b*b). It may be necessary to use struct pointer types as function parameters. Where the real and imaginary parts are entered by the keyboard, the output is normalized, and if the real or imaginary part of the normalized result is a decimal, a decimal is reserved.
Sample input: (Format description: 3 4 is the real and imaginary parts of real numbers separated by spaces respectively)
3 4 Sample Output 0.6+0.8i Example input 2 5 sample output 0.4+0.9i
`1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5#include <cmath>6 using namespacestd;7 intMain ()8 {9     Doubleb;Ten     Doublea1,b1; One      while(~SCANF ("%LF%LF",&a,&b)) A     { -A1=A/SQRT (a*a+b*b); -B1=B/SQRT (a*a+b*b); theprintf"%.1lf+%.1lfi\n", A1,B1); -     } -     return 0; -}`

Algorithm to improve the normalization of complex numbers

Related Keywords:

### Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.