Created
February 7, 2016 08:08
-
-
Save meditans/fb283e54e4108b3b3fac to your computer and use it in GitHub Desktop.
scolaresca.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cmath> | |
| using namespace std; | |
| struct studente | |
| { | |
| string nome; | |
| int eta; | |
| }; | |
| string vecchio(studente * appello, int l) | |
| { | |
| int iMax = 0; | |
| for(int i=0; i<=l-1; i++) | |
| { | |
| if(appello[i].eta > appello[iMax].eta) | |
| iMax = i; | |
| } | |
| return appello[iMax].nome; | |
| } | |
| int main() | |
| { | |
| cout << "Quanti studenti ci sono: "; | |
| int n=0; | |
| cin >> n; | |
| studente scolaresca[n]; | |
| for(int i=0; i<=n-1; i++) | |
| { | |
| cout << "Scrivi nome ed eta dello studente numero " << i << ": "; | |
| cin >> scolaresca[i].nome >> scolaresca[i].eta; | |
| } | |
| cout << "Il vegliardo e' " << vecchio(scolaresca, n) << endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment