#1 2011-01-21 16:34:03

 cieniu

Użytkownik

Skąd: Olesnica
Zarejestrowany: 2010-12-12
Posty: 66
Punktów :   
WWW

lab4 i lab6

Poluje na te zadania... posiada ktoś zrobione?? :) pokazywałem mu 4 z tego zbioru zadań kto tutaj zamieścił to mi marudził, że to nie to... ;P


Strony Oleśnica, najlepsze vlogi w sieci.

Offline

 

#2 2011-01-25 09:14:50

 celudor

Użytkownik

Skąd: Wrocław
Zarejestrowany: 2010-10-20
Posty: 53
Punktów :   

Re: lab4 i lab6

LBA6 - Liczby zespolone



Zesp.h

Kod:

#pragma once
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;


class Zesp
{
public:
    Zesp(double Re=0, double Im=0);
    Zesp(const Zesp& z);
    
    ~Zesp(void);
private:
    // czesc rzeczywista
    double Re;
    // czesc urojona
    double Im;
public:

    // zwraca wartosc Re
    double Realis(void)
    {
        return Re;
    }

    // zwraca wartosc Im
    double Imaginary(void)
    {
        return Im;
    }
    // przeciazenie operatora dodawania
    Zesp operator+(const Zesp b) const;
    // przeciazenie operatora mnozenia
    Zesp operator*(const Zesp& b) const;
    //przeciazenie operaqtora dzielenia
    Zesp operator/(const Zesp& b) const;

    friend ostream& operator<<(ostream&, const Zesp&);
    friend istream& operator>>(istream&,Zesp&);

    
    double Modul(void);
    double Argument(void);
};

Zesp.cpp

Kod:

#include "StdAfx.h"
#include "Zesp.h"

Zesp::Zesp(double Re, double Im)
: Re(Re)
, Im(Im)
{
    cerr << "Konstrukcja " << *this << "\n";
}

Zesp::Zesp(const Zesp& z):Re(z.Re),Im(z.Im)
{
    cerr << "Kopiowanie " << *this << "\n";
}



Zesp::~Zesp(void)
{
    cerr << "Destrukcja " << *this << "\n";
}

// przeciazenie operatora dodawania
Zesp Zesp::operator+(const Zesp b) const
{
    return Zesp(Re+b.Re, Im+b.Im);
}

// przeciazenie operatora mnozenia
Zesp Zesp::operator*(const Zesp& b) const
{
    return Zesp(Re*b.Re-Im*b.Im, Re*b.Im+Im*b.Re);
}

Zesp Zesp::operator/(const Zesp& b) const
{
    return Zesp((Re*b.Re+Im*b.Im)/(b.Re*b.Re+b.Im*b.Im), (Re*b.Im-Im*b.Re)/(b.Re*b.Re+b.Im*b.Im));
}

ostream &operator<<(ostream &wy, const Zesp &z)
{
    wy<<'('<<z.Re<<", "<<z.Im<<')';
    return wy;
}
istream &operator>>(istream &we,Zesp &z)
{
    int k=we==cin;
    if(k) cerr<<"Re= ";
    we>>z.Re;
    if(k) cerr<<"Im= ";
    we>>z.Im;
    return we;
}
double Zesp::Modul(void)
{
    return sqrt(Re*Re+Im*Im);
}

double Zesp::Argument(void)
{
    return asin(Im/Modul()) * 180 / M_PI;
}

Lab6.cpp

Kod:

#include "stdafx.h"
#include "Zesp.h"


int _tmain(int argc, _TCHAR* argv[])
{
    Zesp A(-1,-1);
    Zesp B(0,1);
    Zesp C(A);

    C=A/B;

    cout << "A = " << A << "\nB = " << B << "\nA/B = "<< C << "\n";
    cout << "|A| = " << A.Modul() << "\n";
    cout << "Arg(A) = " << A.Argument() << " deg\n";

    return 0;
}

LAB4 - Zadanie domowe


Kod:

#include "stdafx.h"

int silnia(int n)
{
    fprintf(stderr, "n = %d\n", n);
    if(n > 1)
    {
        return n * silnia(n - 1);
    }
    else
        return 1;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int n;
    fprintf(stderr, "Podaj liczbe ");
    scanf_s("%d", &n);
    printf("%d! = %d\n", n,silnia(n));
    return 0;
}

Ostatnio edytowany przez celudor (2011-01-25 09:19:36)

Offline

 

#3 2011-01-26 16:48:33

 cieniu

Użytkownik

Skąd: Olesnica
Zarejestrowany: 2010-12-12
Posty: 66
Punktów :   
WWW

Re: lab4 i lab6

thx


Strony Oleśnica, najlepsze vlogi w sieci.

Offline

 

#4 2011-01-27 21:15:38

 ShaguaR

Użytkownik

4245729
Skąd: Oleśnica
Zarejestrowany: 2010-11-29
Posty: 195
Punktów :   

Re: lab4 i lab6

celudor ... a moglbys wrzucic LAB6 juz zrobiony i spakowany ? bo jak sam u siebie robie to mi bledy wywala.
z gory thx


Pomogłem ? Daj +
              xDe

http://images.chomikuj.pl/button/sharas.gif

Offline

 

#5 2011-01-27 23:23:23

januszs

Użytkownik

Zarejestrowany: 2010-10-20
Posty: 121
Punktów :   11 

Re: lab4 i lab6

Kod:

long Silnia(int n)
{
  return (n>1) ? n*Silnia(n-1):1;
}

bardziej kompaktowo chyba się już nie da...


Nie pytajcie po co to robię http://images.chomikuj.pl/button/jsszczytna.gif

Offline

 

#6 2011-01-28 09:20:51

 ShaguaR

Użytkownik

4245729
Skąd: Oleśnica
Zarejestrowany: 2010-11-29
Posty: 195
Punktów :   

Re: lab4 i lab6

ale nie chodzi mi o 4 tylko o 6 (liczby zespolone)


Pomogłem ? Daj +
              xDe

http://images.chomikuj.pl/button/sharas.gif

Offline

 

#7 2011-01-28 20:31:10

 celudor

Użytkownik

Skąd: Wrocław
Zarejestrowany: 2010-10-20
Posty: 53
Punktów :   

Re: lab4 i lab6

Offline

 

#8 2011-01-28 22:07:38

 ShaguaR

Użytkownik

4245729
Skąd: Oleśnica
Zarejestrowany: 2010-11-29
Posty: 195
Punktów :   

Re: lab4 i lab6

dzienx


Pomogłem ? Daj +
              xDe

http://images.chomikuj.pl/button/sharas.gif

Offline

 

#9 2011-02-01 09:38:06

Infi

Nowy użytkownik

Zarejestrowany: 2011-01-13
Posty: 3
Punktów :   

Re: lab4 i lab6

mam nadzieje ze jak skorzystam z 6 to nikt sie nie obrazi bo to ostatnie ktore mam mu dostarczyc ; D

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
lista obecności wzór