Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define Lunghezza 30
  4. #define Classe 2
  5. class ALUNNO{
  6. public:
  7. char cognome[Lunghezza];
  8. char nome[Lunghezza];
  9. unsigned int eta;
  10. void leggi(ALUNNO *);
  11. void stampa(ALUNNO*);
  12. void giovane(ALUNNO*);
  13.  
  14. };
  15.  
  16. int main() {
  17. ALUNNO alunno;
  18. alunno.leggi(& alunno);
  19. alunno.stampa(& alunno);
  20. alunno.giovane(& alunno);
  21. return 0;
  22. }
  23. void ALUNNO :: leggi(ALUNNO *a){
  24. for(unsigned int i=0;i < Classe ;i++)
  25. {
  26. cout<<"\n Inserire cognome: ";
  27. cin >> a[i].cognome;
  28. cout<<"\n Inserire nome:";
  29. cin>>a[i].nome;
  30. cout<<"\n inserire eta:";
  31. cin>>a[i].eta;
  32. }
  33. }
  34. void ALUNNO :: stampa(ALUNNO *a){
  35. for(unsigned int i=0;i < Classe ;i++) {
  36. cout<<"\n cognome: "<<endl<<a[i].cognome;
  37. cout<<"\n nome:"<<endl<<a[i].nome;
  38. cout<<"\n eta:"<<endl<<a[i].eta;
  39. }
  40. }
  41. void ALUNNO :: giovane(ALUNNO *a){
  42. unsigned int temp=a[0].eta;
  43. unsigned int i;
  44. for( i=1;i<Classe;i++){
  45. if(a[i].eta < temp)
  46. temp = a[i].eta;
  47. }
  48. cout<<"\n eta minima: "<<temp<<endl;
  49. return;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement