Find the conjugate of a Complex number | C ++ implementation to Find the conjugate of a complex number ; Function to find conjugate of a complex number ; store index of ' + ' ; store index of ' - ' ; print the result ; Driver code ; initialise the complex number
#include <bits/stdc++.h> NEW_LINE using namespace std ; void solve ( string s ) { string z = s ; int l = s . length ( ) ; int i ; if ( s . find ( ' + ' ) < l ) { i = s . find ( ' + ' ) ; replace ( s . begin ( ) , s . end ( ) , ' + ' , ' - ' ) ; } else { i = s . find ( ' - ' ) ; replace ( s . begin ( ) , s . end ( ) , ' - ' , ' + ' ) ; } cout << " Conjugate ▁ of ▁ " << z << " ▁ = ▁ " << s << endl ; } int main ( ) { string s = "3-4i " ; solve ( s ) ; return 0 ; }