Für Vorlesungen, bitte die Webseite verwenden. https://flavigny.de/lecture
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

38 行
622B

  1. #include "fcpp.hh"
  2. struct Complex {
  3. float real;
  4. float imag;
  5. } ;
  6. Complex erzeuge_complex (float re, float im)
  7. {
  8. Complex t;
  9. t.real = re; t.imag = im;
  10. return t;
  11. }
  12. float real (Complex q) {return q.real;}
  13. float imag (Complex q) {return q.imag;}
  14. Complex add_complex (Complex p, Complex q)
  15. {
  16. return erzeuge_complex(real(p) + real(q),
  17. imag(p) + imag(q));
  18. }
  19. // etc
  20. void drucke_complex (Complex p)
  21. {
  22. print(real(p),"+i*",imag(p),0);
  23. }
  24. int main ()
  25. {
  26. Complex p = erzeuge_complex(3.0,4.0);
  27. Complex q = erzeuge_complex(5.0,3.0);
  28. drucke_complex(p);
  29. drucke_complex(q);
  30. drucke_complex(add_complex(p,q));
  31. }