Treceți la conținutul principal

clasa linie cpp

// VALENTINA UNGUROIU - Grupa 1051
 //  Subiectul 13


#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <iostream.h>


class linie;

class statist
{
 int nr_indic;

public:

  double a[10][10];
  linie *vector[10];
  statist(int nind=0);
  int spune_nrindic() {return nr_indic;}
  statist& operator ++();
};

class linie:public statist
{
int nrani;
char *numeindic[20];
int stare[10];

public:
 linie(int ni=0,int ani=0):statist(ni)
 {int i,j;
        cout<<"Dati numarul de ani:";
        cin>>nrani;
  
  cout<<"\n"<<"Dati valorile indicatorilor:"<<"\n";
        
  for (i=0;i<spune_nrindic();i++)
          for(j=0;j<spune_nrani();j++)
                  cin>>a[i][j];
        cout<<endl;
        cout<<"Dati starile celor "<<spune_nrindic()<<" indicatori (1-activ/0-inactiv)"<<"\n";
       for (i=0;i<spune_nrindic();i++)
             cin>>stare[i];
      cout<<endl;
      cout<<"\n"<<"Dati numele indicatorilor:"<<"\n";
      for (i=0;i<spune_nrindic();i++)
          {numeindic[i]=new char[10];
           cin>>numeindic[i];
          }
 }  

    int spune_nrani() {return nrani;}
    double *get_valori(int i);
    int spune_stare(int i);
    char *spune_numeindic(int i)
                        {return numeindic[i];}
 
    void friend operator !=(char var[20],linie p2);
      };




void operator!=(char var[20],linie p2)
{int i=0,gasit=0;
 while  ((i<p2.spune_nrindic()) && (!gasit))
        {if (strcmp(p2.spune_numeindic(i),var)==0)
                {if (p2.spune_stare(i)==1) 
     {p2.stare[i]=0;
      cout<<"Indicatorul "<<var<<" este acum inactiv";
     }

      else {p2.stare[i]=1;
       cout<<"Indicatorul "<<var<<" este acum activ";
       }
                 gasit=1;
                }
         else i++;
  }
 
}





statist::statist(int)
{
cout<<"Dati numarul de indicatori:";
cin>>nr_indic;
 }



int linie::spune_stare(int i)
{return stare[i];
}

double* linie::get_valori(int i)
{int j;
double *x;
x=new double [10];
for (j=0;j<nrani;j++)
x[j]=a[i][j];

return x;
}


double media(double v[20],int n)
{int i;
double s=0;
for (i=0;i<n;i++) s+=v[i];
s=s/n;
return s;
}

double disp(double v[20],int n)
{int i;
double med=media(v,n);
double s=0;
for (i=0;i<n;i++)
   s+=(v[i]-med)*(v[i]-med);
s=s/n;
return s;
}


double abatere(double v[20],int n)
{double d=disp(v,n);
 double s;
 s=sqrt(d);
 return s;
}




void prelucrare(linie p2)
{

int i,j,k;

double (*vpf[3]) (double*,int)={media,disp,abatere};
char *ind_stat[4];
ind_stat[0]=new char[30];
ind_stat[1]=new char[30];
ind_stat[2]=new char[30];
strcpy(ind_stat[0],"Media:");
strcpy(ind_stat[1],"Dispersia:");
strcpy(ind_stat[2],"Abaterea medie patratica:");



int n=p2.spune_nrani();
int m=p2.spune_nrindic();
for(i=0;i<20;i++)
cout<<"\n";

for(i=0;i<m;i++)
        {if (p2.spune_stare(i)==1)
                {cout<<"\n";
                 cout<<p2.spune_numeindic(i)<<endl;
                for(j=0;j<3;j++)
                        {
                         cout<<ind_stat[j];

                         double x[20];
                         int s=0;
                         for(k=0;k<n;k++)
                            x[k]=*(p2.get_valori(i)+k);
                            cout<<vpf[j](x,n)<<endl;
                        }
                }
         else cout<<"Indicatorul "<<p2.spune_numeindic(i)<<" este inactiv !!!"<<endl;
  }
}


void main()
{
 int i,exista;
 char raspuns[2];
 char nume[20];
 linie p2;


 int m=p2.spune_nrindic();

prelucrare(p2);
for(i=0;i<10;i++)
cout<<"\n";

cout<<"Doriti sa schimbati starea unui indicator?";
cin>>raspuns;


if (*raspuns=='d')
        {cout<<"Dati numele indicatorului a carui stare doriti sa o schimbati:";
         cin>>nume;

         i=0;exista=0;
          while ((i<m) && (!exista))
                {
                 if (strcmp(p2.spune_numeindic(i),nume)==0)
                        exista=1;
                 else i++;
                }
        if (!exista) cout<<"\n"<<"Indicatorul nu exista"<<endl;
         else {
               operator!=(nume,p2);
               //for (i=0;i<10;i++) cout<<"\n";
     
    } 
               }

}


Comentarii

Postări populare de pe acest blog

WINDOWS 10 COMPUTER FREEZING PROBLEM SOLVED

good news : a BIOS UPDATE can resolve the problem but just for a Windows 7 on 64 bits o.s. and the system is not stable all the time. even after  bios update the system can freeze.
new info : u can try to low the screen brightness and see if this error appear so often after 
news: last info !!! maybe a virus. scann our system now with an antivirus i generate this error using other device ( a tablet pc) connected in the same network and the laptop i have this problem just freeze  http://thehackernews.com/2013/10/backdoor-found-in-chinese-tenda.html

news : if u use a tenda router this make couse all this problems



what i discover so far :
1.the electric company have many failure and affect the main ISP router/switch for building  also the router/switch installed by the ISP may be affected by overheating and will crash after a long utilisation on heat conditions 2.the router/switch of ISP affect any router of the user between this router and pc/laptop of client 3.the router and any other device of t…

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='+'…

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…