Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- class Complex{
- private:
- float real;
- float imaginar;
- public:
- Complex(float real=0, float imaginar = 0){
- this -> real = real;
- this -> imaginar = imaginar;
- }
- void afisare(){
- printf("%8.4f %+8.4f*i\n", real, imaginar);
- }
- Complex operator + (const Complex &z){
- return Complex(real+z.real, imaginar + z.imaginar);
- }
- Complex operator * (const Complex &z){
- return Complex(real*z.real - imaginar*z.imaginar, real*z.imaginar + imaginar*z.real);
- }
- };
- Complex c(-1.0,.35);
- Complex f(int n){
- if(n == 0)
- return c;
- else {
- Complex z = f(n-1);
- return z*z + c;
- }
- }
- int main(){
- Complex z;
- int n=10;
- for(int i=0;i<n;i++){
- z = f(i);
- printf("f(%d)=",i);
- z.afisare();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement