[text] 1

Viewer

  1. struct Student
  2.  
  3. {
  4.  
  5. string name;
  6.  
  7. string grupa;
  8.  
  9. int year;
  10.  
  11. } ;
  12.  
  13. int Function(struct Student **);
  14.  
  15. int main()
  16.  
  17. {
  18.  
  19. struct Student stud1 = {"Michel","AБ-91",2001};
  20.  
  21. struct Student stud2 = {"Alex","ОБ-92з",2002};
  22.  
  23. struct Student stud3 = {"Iren","rpbi-82",2000};
  24.  
  25. struct Student stud4 = {"Ivan","ikt-802",1999};
  26.  
  27. Student *stud[4]= {&stud1,&stud2,&stud3,&stud4};
  28.  
  29. double S[4];
  30.  
  31. int k=Function(stud);
  32.  
  33. cout<<stud[k]->name<<" "<<stud[k]->grupa<<" "<<stud[k]->year<<endl;
  34.  
  35. return 0;
  36.  
  37. }
  38.  
  39. int Function(struct Student **stud)
  40.  
  41. { int m=stud[0]->year; int k=0;
  42.  
  43. for(int i=0; i<4; i++)
  44.  
  45. if (stud[i]->year>m) m=stud[i]->year, k=i;
  46.  
  47. return k;
  48.  
  49. }

Editor

You can edit this paste and save as new:


File Description
  • 1
  • Paste Code
  • 15 Jun-2021
  • 680 Bytes
You can Share it: