Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- struct Planilla
- {
- vector< pair < string, vector<int> > > Alu; ///Lista de adyacencia
- int N, C;
- void Ingreso()
- {
- cout<<"Cantidad de alumnos: "; cin>>C;
- cout<<"Cantidad de notas por alumno: "; cin>>N;
- Alu.resize(C);
- ///adj = vector <vector <int> > (nodos+1, vector <int> (arista+1, 5));
- for(int i=0; i<C; i++)
- {
- string nombre;
- cin>>nombre;
- Alu[i].first=nombre;
- for(int j=0; j<N; j++)
- {
- float aux;
- cin>>aux;
- Alu[i].second.push_back(aux);
- }
- }
- }
- void Proceso()
- {
- for(int i=0; i<C; i++)
- {
- float sum=0, prom;
- for(int j=0; j<N; j++)
- sum+=Alu[i].second[j];
- prom=sum/N;
- Alu[i].second.push_back(prom);
- }
- }
- void Salida()
- {
- cout<<endl<<endl;
- for(int i=0; i<C; i++)
- {
- float sum=0;
- cout<<Alu[i].first<<" => ";
- for(int j=0; j<N; j++)
- cout << Alu[i].second[j]<<" ";
- cout<<"= "<<Alu[i].second[N]<<endl;
- }
- }
- };
- int main ()
- {
- Planilla P;
- P.Ingreso();
- P.Proceso();
- P.Salida();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment