Created
June 29, 2016 06:35
-
-
Save meditans/00140352cef9a81c496adf43a6a4994b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cmath> | |
using namespace std; | |
// Codice che definisce la struct che rappresenta un numero complesso. Ricordati | |
// che si entra nei campi con la sintassi Variabile.Campo, quindi per esempio | |
// una volta definito un complesso z puoi prendere la parte reale con z.re | |
struct Complesso | |
{ | |
double re; | |
double im; | |
}; | |
int main() | |
{ | |
Complesso z; | |
cout << "Immetti re" << endl; | |
cin >> z.re; | |
cout << "Immetti im" << endl; | |
cin >> z.im; | |
cout << sqrt(z.re*z.re + z.im*z.im) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment