Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define Lunghezza 30
- #define Classe 2
- class ALUNNO{
- public:
- char cognome[Lunghezza];
- char nome[Lunghezza];
- unsigned int eta;
- void leggi(ALUNNO *);
- void stampa(ALUNNO*);
- void giovane(ALUNNO*);
- };
- int main() {
- ALUNNO alunno;
- alunno.leggi(& alunno);
- alunno.stampa(& alunno);
- alunno.giovane(& alunno);
- return 0;
- }
- void ALUNNO :: leggi(ALUNNO *a){
- for(unsigned int i=0;i < Classe ;i++)
- {
- cout<<"\n Inserire cognome: ";
- cin >> a[i].cognome;
- cout<<"\n Inserire nome:";
- cin>>a[i].nome;
- cout<<"\n inserire eta:";
- cin>>a[i].eta;
- }
- }
- void ALUNNO :: stampa(ALUNNO *a){
- for(unsigned int i=0;i < Classe ;i++) {
- cout<<"\n cognome: "<<endl<<a[i].cognome;
- cout<<"\n nome:"<<endl<<a[i].nome;
- cout<<"\n eta:"<<endl<<a[i].eta;
- }
- }
- void ALUNNO :: giovane(ALUNNO *a){
- unsigned int temp=a[0].eta;
- unsigned int i;
- for( i=1;i<Classe;i++){
- if(a[i].eta < temp)
- temp = a[i].eta;
- }
- cout<<"\n eta minima: "<<temp<<endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement