Skip to content
Snippets Groups Projects
Commit 35720a19 authored by Slim Medimegh's avatar Slim Medimegh
Browse files

Ajout des exercices WIMS pour le thème struct_ fonction_1

parent 0e5f08a3
No related branches found
No related tags found
No related merge requests found
#include<iostream>
using namespace std;
struct complexe {
float re, im;
};
complexe somme(complexe a, complexe b) {
complexe c;
c.re=a.re+b.re;
c.im=a.im+b.im;
return (c);
}
complexe produit(complexe a, complexe b) {
complexe c;
c.re = (a.re * b.re)-(a.im * b.im);
c.im = (a.re * b.im)+(a.im * b.re);
return (c);
}
int main() {
complexe c1, c2,c3,c4;
c1.re = 1;
c1.im = 0;
c2.re = 1;
c2.im = 0;
c3= somme(c1,c2);
cout<<c3.re<< "+" <<c3.im<<"i"<<endl;
c4= produit(c1,c2);
cout<<c4.re<< "+" <<c4.im<<"i"<<endl;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment