wtorek, 4 listopada 2014

#include <iostream>

using namespace std;


class wektor
{
    public:
        wektor(const int );
        virtual ~wektor();
        //void usun();
        void wpisz( );
        void wypisz();
        int wymiar();


    private:

        int k; // wymiar
        float *w;


};

#include "wektor.h"
#include <iostream>

 using namespace std;

wektor::wektor(const int n)
{
 int t=0;
k=n;
    new float [k];
    w= new float [k];

    for (int i=1; i<=k; i++)
    {
        w[i]=0;
    }
}

wektor::~wektor()
{

    delete w;
}

int wektor :: wymiar()
{
    return k;
}


void wektor :: wpisz()
{
    for(int i=1; i<=wymiar(); i++)
        cin>> w[i];

}

//a

#include "a.h"

#include <iostream>

using namespace std;

template <class T>

 A<T> :: A(const T& a, const T& b)
        {
            x=a;
            y=b;
        }


template <class T>
    A<T> :: A()
    {//konstruktor domyslny
       T x();
       T y();
    }

template <class T>
     A<T>:: ~A()
        {
            cout<<"Destruktor"<<endl;

        }


template <class T>

       A<T>:: A(const A& z)
        {
            x=z.x;
            y=z.y;
        }


template <class T>

ostream& operator << (ostream& wy,  A<T>& z)
{
    wy<<z.x<<","<<z.y<<endl;
    return wy;
}

//FUNKCJE ZESPOLONE

#include <iostream>
#include "zespolona.h"

using namespace std;

extern const Zespolona operator + ( Zespolona&, Zespolona&);
ostream& operator << (ostream& wy,Zespolona &z);
istream& operator>> (istream& we, Zespolona& z);
float max ( float A[3]);
extern void wpisywanie (Zespolona&, Zespolona &, Zespolona& );

//ZESPOLONE DEFINICJE

#include <iostream>
#include"funkcjezespolone.cpp"
#include"zespolona.h"
#include <stdarg.h>

using namespace std;



 const Zespolona operator + ( Zespolona&w, Zespolona& z)
 {
     return Zespolona(z.Re() + w.Re() ,z.Im() + w.Im());
 }


ostream& operator << (ostream& wy,Zespolona &z)
{
    wy<< z.Re()<<"+"<< z.Im()<<"i"<<endl;
    return wy;
}

istream& operator>> (istream& we, Zespolona& z)
{
   we>>z.a;
   we>>z.b;
   return we;
}





    float max ( float A[3])
{
    int b=0;
    float a=A[0];
    for(int i=1; i<3; i++)
    {
      if(A[i]>a) {a=A[i]; b=i;}
    }

    return b;
}

void wpisywanie (Zespolona& z1, Zespolona & z2, Zespolona& z3 )
{


float B[3];
B[0]=z1.Re();
B[1]=z2.Re();
B[2]=z3.Re();


float C[3];
C[0]=z1.Im();
C[1]=z2.Im();
C[2]=z3.Im();

int x= max(C);
if(max(C)== max(B))
    cout<<"Max =" <<B[x]<<"+"<<C[x]<<"i"<<endl;

else cout<<"Niestety, nie ma najwiekszego"<<endl;

}



#include <iostream>
#include"macierz.h"
using namespace std;


int main()
{cout<<"Podaj wymiary Twojej macierzy\n";
    int w,k;
 cin>>w>>k;
    Macierz A(w,k);
 cout<<"Wpisz liczby z Twej macierzy\n";
 cin>>A;
 cout<<"\nTwoja macierz to:\n\n";
 cout<<A;
 /*cout<<"Druga macierz ma wymiary\n";
    int W,K;
 cin>>W>>K;
    Macierz X(W,K);

 Macierz A(3,3), B(3,3);
 cin>>A;
 cout<<A<<"\n";
 B=A;
 cout<<"\n"<<B;
 A.zmiana(0,0,4.5);
 cout<<"\n"<<A;
 cout<<"\n"<<B;
 */
 int wyznacznik=0;
 wyznacznik=A.det();
 cout<<"\n det="<<wyznacznik;
     return 0;
}


#include<iostream>
#include<cstdlib>

using namespace std;

 class Macierz
       {
         
        private:
        int a,b;
        double **macierz;//zaczyn tablicy
        int sztuczna;//0-sztuczna,1-nie sztuczna
       
       
        public:
           
        Macierz(int w, int k);
        Macierz(Macierz&A);
        ~Macierz();
       
        friend istream& operator >> (istream&,Macierz&);
        friend ostream& operator << (ostream&,Macierz&);
        void zmiana (int, int, double);
        double det();
        Macierz& operator = (Macierz&);
        Macierz& operator+ (Macierz&);
        /*
        Macierz& operator- (Macierz&);
        Macierz& operator* (Macierz&);
        friend Macierz& operator* (double,Macierz&);
        Macierz& operator* (double);
        */
        };