Skip to content

Instantly share code, notes, and snippets.

@meditans
Created February 7, 2016 08:08
Show Gist options
  • Select an option

  • Save meditans/fb283e54e4108b3b3fac to your computer and use it in GitHub Desktop.

Select an option

Save meditans/fb283e54e4108b3b3fac to your computer and use it in GitHub Desktop.
scolaresca.cpp
#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