Treceți la conținutul principal

angajati cpp

// PROIECT LA LIMBAJE EVOLUATE: BILET NR. 10


#include "stdafx.h"
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

//********************CLASA DE BAZA**********************************
class bd_ang;
class angajat
{
protected:
 int varsta,vechime;
 long cnp;
public:
 friend class bd_ang;
 char nume[20];
 int marca;
 long salariu;
// angajat();
 angajat(char *,long,int,int,long,int);
// angajat(angajat & );
 ~angajat();
 void print();
 int spune_varsta() {return varsta;}
 int spune_vechime() {return vechime;}
 long spune_cnp() {return cnp;}
 friend ostream &operator<<(ostream & , angajat);
 friend istream &operator>>(istream & , angajat &);
 virtual long calcul_salariu(){return salariu;}
 long operator +(long suma){salariu+=suma; return salariu;}
 long operator -(long suma){salariu-=suma; return salariu;}
 operator long(){return salariu;}//cast conversie Angajat in long
 operator int(){return varsta;}//cast conversie Angajat in int
 operator char*(){return nume;}//cast conversie Angajat in char *
 long operator +(angajat &a){ return salariu+=a.salariu;}//adun obiecte
 long operator -(angajat &a){ return salariu-=a.salariu;}//scad obiecte
 void operator ++(){++varsta;++vechime;}
};

//

angajat::angajat(char n[]="X",long c=0,int m=0,
   int v=0,long sal=0,int vech=0)
   :salariu(sal),cnp(c),marca(m),varsta(v),vechime(vech)
{
 strcpy(nume,n); 
}

angajat::~angajat() 
{
}

/*angajat::angajat()
{
 salariu=0;
 cnp=0;
 marca=0;
 varsta=0;
 vechime=0;
 strcpy(nume,"X ");
 total++;
}*/

/*angajat::angajat(angajat &a)
{

 salariu=a.salariu;
 cnp=a.cnp;
 marca=a.marca;
 varsta=a.varsta;
 vechime=a.vechime;
 strcpy(nume,a.nume);
 total++;
}*/

void angajat::print()
{
 cout<<"\nNumele angajatului:"<<nume<<endl;
 cout<<"Cod numeric personal: "<<spune_cnp()<<endl;
    cout<<"Marca : "<<marca<<endl;
 cout<<"Varsta : "<<spune_varsta()<<endl;
    cout<<"Vechimea : "<<spune_vechime()<<endl;
 cout<<"Salariul : "<<calcul_salariu()<<endl;/*
 cout<<"\n"<<nume<<"  "<<spune_cnp()<<"  "<<marca<<"  "<<spune_varsta()
  <<"  "<<spune_vechime()<<"  "<<calcul_salariu();*/
}

ostream &operator<<(ostream & iesire,angajat a)
{
 iesire <<a.nume<<"  "<<a.spune_cnp()<<"  "<<a.marca<<"  "
  <<a.spune_varsta()<<"  "<<a.spune_vechime()<<"  "
  <<a.calcul_salariu();
 return iesire;
}

istream &operator>>(istream & intrare, angajat &a)
{
 cout<<"Numele noului angajat: "; intrare>>a.nume;
 cout<<"Cod numeric personal: ";  intrare>>a.cnp;
 cout<<"Marca: ";                 intrare>>a.marca;
 cout<<"Varsta:  ";        intrare>>a.varsta;
 cout<<"Vechimea:  ";       intrare>>a.vechime;
 cout<<"Salariu: ";               intrare>>a.salariu;
 return intrare;
}


//*********************** CLASA INDEX *******************************
class bd_ang
{
public:
 friend class angajat;
 static int total;
 static angajat *lista[20];
 static char cautare_binara(int, int &);
 void inserare(angajat *);
 static void stergere(angajat *);
 angajat * operator[](int);
 static void afisare();
};

angajat * bd_ang::lista[20];
int bd_ang::total = 0;

void bd_ang::inserare(angajat *pa)
{
 int i, poz;

 if (!bd_ang::cautare_binara(pa->marca,poz)) {
  for(i=bd_ang::total;i>poz;i--) {
   bd_ang::lista[i]=bd_ang::lista[i-1];
  }
  bd_ang::lista[poz]=pa;
 }
 bd_ang::total++;
}

angajat *bd_ang::operator[](int marca)
{
 int poz;
 if(cautare_binara(marca,poz))return lista[poz];
 else return NULL;
}

char bd_ang::cautare_binara(int marca,int &poz)
{
 int i=0, sf=bd_ang::total, m;
 if(bd_ang::total==0)
 {
  poz=0;
  return 0;
 }
 while(i<sf)
 {
  m=(i+sf)/2;
  if (bd_ang::lista[m]->marca==marca)
  {
   poz=m;
   return 1;
  }
  if (bd_ang::lista[m]->marca<marca) i=m+1;
  else sf=m-1;
 }
 poz=i;
 return 0;
}

void bd_ang::stergere(angajat *pa)
{
 int poz;

 if (bd_ang::cautare_binara(pa->marca,poz)) {
  for(;poz<bd_ang::total;poz++)
   bd_ang::lista[poz]=bd_ang::lista[poz+1];
 }
 bd_ang::total--;
}

void bd_ang::afisare()
{
 int i;
 cout<<endl;
 for(i=0;i<bd_ang::total;i++)
 {
  /*cout<<"\n"<<bd_ang::lista[i]->marca<<" "
   <<bd_ang::lista[i]->nume<<" "
   <<bd_ang::lista[i]->spune_cnp()<<" "
   <<bd_ang::lista[i]->spune_varsta()<<" "
   <<bd_ang::lista[i]->spune_vechime()<<" "
   <<bd_ang::lista[i]->calcul_salariu()<<endl;*/
  bd_ang::lista[i]->print();
 }
      //cout<<*(bd_ang::lista[i])<<endl;
}


//************************* CLASA DERIVATA 1 ******************

class angajat_acord :public angajat
{
 long salariu_piesa;
 int nr_piese;
public:
 angajat_acord(char n[]="X",long c=0,int m=0,
   int v=0,long sal=0,long s_p=0,int nr=0,int vech=0)
   :angajat(n,c,m,v,vech)
 {
  salariu_piesa=s_p;
  nr_piese=nr;
 }
 long spune_sal_p(){return salariu_piesa;}
 int spune_nr_p(){return nr_piese;}
 friend ostream &operator<<(ostream & , angajat_acord);
 friend istream &operator>>(istream & , angajat_acord &);
 long calcul_salariu(){ salariu=salariu_piesa*nr_piese; return salariu;}
 void print()
 {
  angajat::print();
  cout<<"Salariu pe piesa lucrata:"<<spune_sal_p()<<endl;
  cout<<"Nr. piese lucrate: "<<spune_nr_p()<<endl;
 }
};

ostream &operator<<(ostream & iesire,angajat_acord a)
{
 iesire<<a.nume<<"  "<<a.spune_cnp()<<"  "<<a.marca<<"  "
  <<a.spune_varsta()<<"  "<<a.spune_vechime()<<"  "
  <<a.calcul_salariu();
 return iesire;
}

istream &operator>>(istream & intrare, angajat_acord &a)
{
 cout<<"Numele noului angajat: "; intrare>>a.nume;
 cout<<"Cod numeric personal: ";  intrare>>a.cnp;
 cout<<"Marca: ";                 intrare>>a.marca;
 cout<<"Varsta:  ";        intrare>>a.varsta;
 cout<<"Vechimea:  ";       intrare>>a.vechime;
 cout<<"Salariu pe piesa: ";      intrare>>a.salariu_piesa;
 cout<<"Numar de piese: ";        intrare>>a.nr_piese;
 return intrare;
}


//********************* CLASA DERIVATA 2 ***********************

class angajat_cu_ziua :public angajat
{
 long salariu_zi;
 int nr_zile;
public:
 angajat_cu_ziua(char n[]="X",long c=0,int m=0,
   int v=0,long sal=0,long s_z=0,int nr=0,int vech=0)
   :angajat(n,c,m,v,vech)
 {
  salariu_zi=s_z;
  nr_zile=nr;
 }
 long spune_sal_zi(){return salariu_zi;}
 int spune_nr_zile(){return nr_zile;}
 friend ostream &operator<<(ostream & , angajat_cu_ziua);
 friend istream &operator>>(istream & , angajat_cu_ziua &);
 long calcul_salariu(){ salariu=salariu_zi*nr_zile;return salariu;}
 void print()
 {
  angajat::print();
  cout<<"Salariu pe zi:"<<spune_sal_zi()<<endl;
  cout<<"Nr. zile lucrate: "<<spune_nr_zile()<<endl;
 }
};

ostream &operator<<(ostream & iesire,angajat_cu_ziua a)
{
 iesire<<a.nume<<"  "<<a.spune_cnp()<<"  "<<a.marca<<"  "
  <<a.spune_varsta()<<"  "<<a.spune_vechime()<<"  "
  <<a.calcul_salariu();
 return iesire;
}

istream &operator>>(istream & intrare, angajat_cu_ziua &a)
{
 cout<<"Numele noului angajat: "; intrare>>a.nume;
 cout<<"Cod numeric personal: ";  intrare>>a.cnp;
 cout<<"Marca: ";                 intrare>>a.marca;
 cout<<"Varsta:  ";        intrare>>a.varsta;
 cout<<"Vechimea:  ";       intrare>>a.vechime;
 cout<<"Salariu pe zi: ";         intrare>>a.salariu_zi;
 cout<<"Numar zile: ";            intrare>>a.nr_zile;
 return intrare;
}


//************************* MENIU*************************

void meniu()
{
 cout<<"\nAdaugare angajat ---------------------------------- 1"<<endl;
 cout<<"Adaugare angajat in acord ------------------------- 2"<<endl;
 cout<<"Adaugare angajat cu ziua -------------------------- 3"<<endl;
 cout<<"Afisare lista angajati ---------------------------- 4"<<endl;
 cout<<"Concediere angajat -------------------------------- 5"<<endl;
 cout<<"Cautare angajat dupa marca ------------------------ 6"<<endl;
 cout<<"Oferire de prime (adun suma k la salariu) --------- 7"<<endl;
 cout<<"Retinere din salariu (scad suma k din salariu) ---- 8"<<endl;
 cout<<"Fond de salarii (supraincarcare + de obiecte)------ 9"<<endl;
 cout<<"Media de varsta (cast pt. conversie in int)-------- 10"<<endl;
 cout<<"Incrementare varsta si vechimea-------------------- 11"<<endl;
 cout<<"Terminare ----------------------------------------- 0"<<endl;
 cout<<"\nIntroduceti optiunea: "<<endl;
}


//******************** PROGRAM PRINCIPAL ******************

int main(int argc, char* argv[])
{
 bd_ang bd;
 angajat a("",0,0,0,0,0);
 angajat_acord ang;
 angajat_cu_ziua a_z;
 int opt,marca,poz,i;
 long suma;
 do
 {
  do
  {
   meniu();
   cin>>opt;
  }while(opt<0 || opt>13);
  switch(opt) {
   case 1: 
    cin>>a;
    bd.inserare(&a);
    cout<<"\n"<<a<<endl;
    break; 
   case 2:
    cin>>ang;
    bd.inserare(&ang);
    cout<<"\n"<<ang<<endl;
    break;
   case 3:
    cin>>a_z;
    bd.inserare(&a_z);
    cout<<"\n"<<a_z<<endl;
    break;
   case 4:
    cout<<"\nAngajatii sunt:"<<endl;
    bd_ang::afisare();
    break;
   case 5:
    cout<<"\nIntroduceti marca angajatului de concediat:";
    cin>>marca;
    if(bd_ang::cautare_binara(marca,poz))
      bd_ang::stergere(bd_ang::lista[poz]);
    break;
   case 6:
    cout<<"\nIntroduceti marca angajatului: ";
    cin>>marca;
    if(bd_ang::cautare_binara(marca,poz))
     {
      bd_ang::lista[poz]->print();
     }
    break;
   case 7:
    cout<<"\nIntroduceti suma de adaugat la salariu: ";
    cin>>suma;
    for( i=0;i<bd_ang::total;i++)
    {
     bd_ang::lista[i]->salariu = (*(bd_ang::lista[i])) + suma;
    }
    bd_ang::afisare();
    break;
   case 8:
    cout<<"\nIntroduceti suma de retinut din salariu: ";
    cin>>suma;
    for( i=0;i<bd_ang::total;i++)
    {
     bd_ang::lista[i]->salariu = (*(bd_ang::lista[i])) - suma;
    }
    bd_ang::afisare();
    break;
   case 9:
    suma=0;
    for(i=0;i<bd_ang::total;i++)
     suma+=bd_ang::lista[i]->calcul_salariu();
    cout<<"\nFondul de salarii este: "<<suma;
    break;
   case 10:
    suma=0;
    for(i=0;i<bd_ang::total;i++)
     suma+=(int)*(bd_ang::lista[i]);
    cout<<"\nMedia de varsta in firma: "<<suma/bd_ang::total;
    break;
   case 11:
    for(i=0;i<bd_ang::total;i++)
     (*(bd_ang::lista[i]))++;
    bd_ang::afisare();
    break;
   case 0:
    return 0;
    break;
  }
  getch();
 }while(opt);
}

Comentarii

Postări populare de pe acest blog

program principal cpp

#include "clasa.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define DELAY 9000000 void delay() { for(long i=0;i<DELAY;i++); } //constructor cu initializare de la tastatura BigInt::BigInt() {char x; signed char t[400]; int i; printf("\nNumarul cu semn "); do s=getche(); while((s!='+')&&(s!='-')); n=0; do {x=getche(); t[n]=x-'0'; n++; } while((x>='0')&&(x<='9')); n--; for(i=0;i<n;i++) nr[i]=t[n-i-1]; } //constructor cu initializare prin parametri BigInt::BigInt(char semn,signed char numar[],int dim) {int i; s=semn; n=dim; for(i=0;i<n;i++) nr[i]=numar[n-i-1]; } //transform un int negativ in pozitiv int BigInt::Pozitiv(int x) {int a,vb; a=0; vb=0; while(vb==0) if((x+a)==0) vb=1; else a=a+1; x=a; return x; } //constructor dintr-un nr int obisnuit BigInt::BigInt(int x) {int i; if(x>=0) s='+'…

NUMERE PRIME ALGORITM C++

// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile

74111121313417374414124343447 if u know the red part you can generate the orange part
1 0 1 111112222 1 1 23

o aplicatie php localitati romania

//APLICATIA SE REFERA LA BAZA DE DATE SIRUTA

//dragtable.js


/* dragtable v1.0 June 26, 2008 Dan Vanderkam, http://danvk.org/dragtable/ http://code.google.com/p/dragtable/ \Bsortabledraggable\B Instructions: - Download this file - Add <script src="dragtable.js"></script> to your HTML. - Add class="draggable" to any table you might like to reorder. - Drag the headers around to reorder them. This is code was based on: - Stuart Langridge's SortTable (kryogenix.org/code/browser/sorttable) - Mike Hall's draggable class (http://www.brainjar.com/dhtml/drag/) - A discussion of permuting table columns on comp.lang.javascript Licensed under the MIT license. */ // Here's the notice from Mike Hall's draggable script: //***************************************************************************** // Do not remove this notice. // // Copyright 2001 by Mike Hall. // See http…