Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "listIOEstudiant.hh"
- bool pert_llista_est(const list<Estudiant>& l, int x, int& y, bool& s)
- /* Pre: cert */
- /* Post: El resultat indica si x hi es o no a l */
- {
- bool b = false;
- list<Estudiant>::const_iterator it = l.begin();
- while (it != l.end() and not b){
- if ((*it).consultar_DNI() == x) {
- b= true;
- if ((*it).te_nota()) {
- y = (*it).consultar_nota();
- s = true;
- }
- }
- else ++it;
- }
- return b;
- }
- int main(){
- list <Estudiant> l;
- cout << "Entra llista d'estudiants (acabada per 0): " << endl;
- llegir_llista_estudiants(l,0);
- cout << "DNI a cercar: ";
- int x = readint();
- int y;
- bool s = false;
- bool b = pert_llista_est(l,x,y,s);
- if (b) {
- cout << "l'estudiant " << x << " esta a la llista ";
- if (s) cout << "i te nota " << y;
- else cout << "pero no te nota";
- cout << endl;
- }
- else cout << "l'estudiant no hi és" << endl;
- escriure_llista_int(l);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement