Skip to content

Instantly share code, notes, and snippets.

@meditans
Created June 29, 2016 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meditans/00140352cef9a81c496adf43a6a4994b to your computer and use it in GitHub Desktop.
Save meditans/00140352cef9a81c496adf43a6a4994b to your computer and use it in GitHub Desktop.
#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