Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstring>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- ifstream f("date.in");
- struct nod
- {
- char nume[99];
- float med;
- nod *pred, *urm;
- }*c, *p, *u;
- int med=0;
- void creare()
- {
- char x[99];
- float y;
- c = new nod;
- c -> pred = NULL;
- c -> urm = NULL;
- f>>x;
- strcpy(c->nume,x);
- f>>y;
- c->med=y;
- p = c;
- u = c;
- while(f>>x>>y)
- {
- c = new nod;
- strcpy(c->nume,x);
- c->med=y;
- u -> urm = c;
- c -> pred = u;
- c -> urm = NULL;
- u = c;
- }
- }
- void afisare()
- {
- c = p;
- while(c)
- {
- cout << endl;
- cout << c -> nume << "-"<<c->med;
- c = c -> urm;
- }
- }
- void medmax()
- {
- cout<<endl;
- c=p;
- nod *maxi;
- maxi=p;
- while(c)
- {
- if(c->med>maxi->med)
- maxi=c;
- c=c->urm;
- }
- cout<<"Media cea mai mare :"<<maxi->nume<<"-"<<maxi->med;
- }
- void intreoptsizece()
- {
- cout<<endl<<"Mediile intre 8 si 10:";
- c=p;
- while(c)
- {
- if(c->med>8&&c->med<=10)
- cout<<c->nume<<" ";
- c=c->urm;
- }
- }
- void cautare()
- {
- c=p;
- char x[99];
- cout<<endl<<"Cautati:";
- cin>>x;
- cout<<"Media lui "
- <<x<< " este ";
- while(c)
- {
- if(strcmp(x,c->nume)==0)
- cout<<c->med<<" ";
- c=c->urm;
- }
- }
- void mediepeclasa()
- {
- float med=0,k=0;
- c=p;
- while(c)
- {
- med=med+c->med;
- k++;
- c=c->urm;
- }
- cout<<endl<<"Media pe clasa:";
- cout<<med/k;
- }
- int main()
- {
- creare();
- afisare();
- medmax();
- intreoptsizece();
- cautare();
- mediepeclasa();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement