Advertisement
PIBogdanov

sg

Mar 1st, 2024
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5. #include <Windows.h>
  6. #include <conio.h>
  7.  
  8. #pragma warning(disable : 4996)
  9.  
  10. #define MaxCharacters 100
  11.  
  12. #define MinGroupsCount 1
  13. #define MaxGroupsCount 6
  14.  
  15. #define MinStudentsInTheGroupCount 2
  16. #define MaxStudentsInTheGroupCount 30
  17.  
  18. #define MinSubjectsCount 2
  19. #define MaxSubjectsCount 10
  20.  
  21. #define MinGrade 2.0f
  22. #define MaxGrade 6.0f
  23.  
  24. /*
  25. typedef struct
  26. {
  27.     char** subjectNames;
  28.    
  29.     unsigned short subjectsCount;
  30. } Subject;
  31.  
  32. typedef struct
  33. {
  34.     Subject* subjects;
  35.  
  36.     float** grades;
  37.  
  38.     char** studentNames;
  39.  
  40.     char** facultyNumbers;
  41. } Student;
  42.  
  43. typedef struct
  44. {
  45.     Student* students;
  46.  
  47.     unsigned short* studentsInTheGroupsCount;
  48.  
  49.     char** groupNames;
  50.  
  51.     unsigned short groupsCount;
  52. } Group;
  53.  
  54. typedef struct
  55. {
  56.     Group* groups;
  57.  
  58.     char** majorNames;
  59.  
  60.     unsigned short majorsCount;
  61. } Major;
  62.  
  63. typedef struct
  64. {
  65.     Major* majors;
  66.  
  67.     char** facultyNames;
  68.  
  69.     unsigned short facultiesCount;
  70. } Faculty;
  71.  
  72. typedef struct
  73. {
  74.     Faculty* faculties;
  75.  
  76.     char** universityNames;
  77.  
  78.     unsigned short universitiesCount;
  79. } University;
  80. */
  81.  
  82. typedef struct
  83. {
  84.     float** grades;
  85.  
  86.     char** studentNames;
  87.  
  88.     char** facultyNumbers;
  89.  
  90.     char** subjectNames;
  91.  
  92.     unsigned short studentsInTheGroupCount;
  93.  
  94.     unsigned short subjectsCount;
  95. } Student;
  96.  
  97. void inputStudentsInTheGroupCount(Student*);
  98.  
  99. void initializeStudentsInTheGroupCount(Student*, unsigned short);
  100.  
  101. void inputSubjectsCount(Student*);
  102.  
  103. void initializeSubjectsCount(Student*, unsigned short);
  104.  
  105. void inputSubjectNames(Student*);
  106.  
  107. void initialiseSubjectNames(Student*, char[][MaxSubjectsCount]);
  108.  
  109. void freeSubjectNames(Student*);
  110.  
  111. void inputStudentNames(Student*);
  112.  
  113. void inputStudentName(Student*, char[][MaxCharacters]);
  114.  
  115. void initialiseStudentNames(Student*, char[][MaxSubjectsCount]);
  116.  
  117. void freeStudentNames(Student*);
  118.  
  119. void inputFacultyNumbers(Student*);
  120.  
  121. void inputFacultyNumber(Student*, char[][MaxCharacters]);
  122.  
  123. void initialiseFacultyNumbers(Student*, char[][MaxCharacters]);
  124.  
  125. void freeFacultyNumbers(Student*);
  126.  
  127. void inputGrades(Student*);
  128.  
  129. void inputGrade(Student*, float[][MaxSubjectsCount]);
  130.  
  131. bool isValidGrade(float);
  132.  
  133. void initialiseGrades(Student*, float[][MaxSubjectsCount]);
  134.  
  135. void freeGrades(Student*);
  136.  
  137. void inputStudentInformation(Student*);
  138.  
  139. void printStudentInformation(Student*);
  140.  
  141. void initialiseStructMembers(Student*);
  142.  
  143. void freeStructMembers(Student*);
  144.  
  145. void removeNewlineCharacterIfItExists(char*);
  146.  
  147. void pressTheEnterKeyToContinue();
  148.  
  149. void isCursorVisible(bool);
  150.  
  151. void clearTheInputBufferIfNeededAndTheScreen(bool, bool);
  152.  
  153. void mainMenu(Student*);
  154.  
  155. void displayMenu(char*[], unsigned short, unsigned short);
  156.  
  157. void menuControls(Student*, unsigned short*, unsigned short, bool*);
  158.  
  159. void searchForAStudent(Student*);
  160.  
  161. bool isStudentPresentInTheGroup(Student*, char[], unsigned short*);
  162.  
  163. void printInformationAboutTheStudent(Student*, unsigned short);
  164.  
  165. int main()
  166. {
  167.     isCursorVisible(false);
  168.  
  169.     Student students;
  170.  
  171.     initialiseStructMembers(&students);
  172.  
  173.     clearTheInputBufferIfNeededAndTheScreen(false, true);
  174.  
  175.     printStudentInformation(&students);
  176.  
  177.     pressTheEnterKeyToContinue();
  178.  
  179.     mainMenu(&students);
  180.  
  181.     return 0;
  182. }
  183.  
  184. void inputStudentsInTheGroupCount(Student* students)
  185. {
  186.     unsigned short studentsInTheGroupCount;
  187.  
  188.     inputStudentsInTheGroupCount:
  189.     printf("How many students are in the group? [%hu - %hu]\nStudents in the group count: ", MinStudentsInTheGroupCount, MaxStudentsInTheGroupCount);
  190.     scanf("%hu", &studentsInTheGroupCount);
  191.  
  192.     if ( (studentsInTheGroupCount < MinStudentsInTheGroupCount) || (studentsInTheGroupCount > MaxStudentsInTheGroupCount) )
  193.     {
  194.         printf("\n\nInvalid input!\n\n");
  195.  
  196.         goto inputStudentsInTheGroupCount;
  197.     }
  198.  
  199.     initializeStudentsInTheGroupCount(students, studentsInTheGroupCount);
  200. }
  201.  
  202. void initializeStudentsInTheGroupCount(Student* students, unsigned short studentsInTheGroupCount)
  203. {
  204.     students->studentsInTheGroupCount = studentsInTheGroupCount;
  205. }
  206.  
  207. void inputSubjectsCount(Student* students)
  208. {
  209.     unsigned short subjectsCount;
  210.  
  211.     inputSubjectsCount:
  212.     printf("How many subjects do the students have? [%hu - %hu]\nStudents in the group count: ", MinSubjectsCount, MaxSubjectsCount);
  213.     scanf("%hu", &subjectsCount);
  214.  
  215.     if ( (subjectsCount < MinSubjectsCount) || (subjectsCount > MaxSubjectsCount) )
  216.     {
  217.         printf("\n\nInvalid input!\n\n");
  218.  
  219.         goto inputSubjectsCount;
  220.     }
  221.  
  222.     initializeSubjectsCount(students, subjectsCount);
  223. }
  224.  
  225. void initializeSubjectsCount(Student* students, unsigned short subjectsCount)
  226. {
  227.     students->subjectsCount = subjectsCount;
  228. }
  229.  
  230. void inputSubjectNames(Student* students)
  231. {
  232.     printf("Input the names of the subjects:\n\n\n");
  233.  
  234.     char subjectNames[MaxSubjectsCount][MaxCharacters] = { { '\0' } };
  235.  
  236.     for (unsigned short i = 0; i < students->subjectsCount; i++)
  237.     {
  238.         printf("Subject %hu: ", i + 1);
  239.  
  240.         while (fgets(subjectNames[i], MaxCharacters, stdin) == NULL)
  241.         {
  242.             printf("\n\nToo many inputted characters! The max value of characters is %hu. Input a new subject name.\n\nSubject %hu: ", MaxCharacters, i + 1);
  243.         }
  244.  
  245.         removeNewlineCharacterIfItExists(subjectNames[i]);
  246.     }
  247.  
  248.     initialiseSubjectNames(students, subjectNames);
  249. }
  250.  
  251. void initialiseSubjectNames(Student* students, char subjectNames[][MaxCharacters])
  252. {
  253.     students->subjectNames = malloc(students->subjectsCount * sizeof(char*));
  254.  
  255.     for (size_t i = 0; i < students->subjectsCount; i++)
  256.     {
  257.         students->subjectNames[i] = strdup(subjectNames[i]);
  258.     }
  259. }
  260.  
  261. void freeSubjectNames(Student* students)
  262. {
  263.     for (size_t i = 0; i < students->subjectsCount; i++)
  264.     {
  265.         free(students->subjectNames[i]);
  266.     }
  267.  
  268.     free(students->subjectNames);
  269. }
  270.  
  271. void inputStudentNames(Student* students)
  272. {
  273.     printf("Input the names of the students:\n\n\n");
  274.  
  275.     char studentNames[MaxStudentsInTheGroupCount][MaxCharacters] = { { '\0' } };
  276.  
  277.     for (unsigned short i = 0; i < students->studentsInTheGroupCount; i++)
  278.     {
  279.         printf("Student %hu: \n", i + 1);
  280.  
  281.         printf("Name: ");
  282.  
  283.         while (fgets(studentNames[i], MaxCharacters, stdin) == NULL)
  284.         {
  285.             printf("\n\nToo many inputted characters! The max value of characters is %hu. Input a new student name.\n\nName: ", MaxCharacters);
  286.         }
  287.  
  288.         removeNewlineCharacterIfItExists(studentNames[i]);
  289.  
  290.         printf("\n\n");
  291.     }
  292.  
  293.     initialiseStudentNames(students, studentNames);
  294. }
  295.  
  296. void inputStudentName(Student* students, char studentNames[][MaxCharacters])
  297. {
  298.     for (unsigned short i = 0; i < students->studentsInTheGroupCount; i++)
  299.     {
  300.         if (!strcmp(studentNames[i], "\0"))
  301.         {
  302.             while (fgets(studentNames[i], MaxCharacters, stdin) == NULL)
  303.             {
  304.                 printf("\n\nToo many inputted characters! The max value of characters is %hu. Input a new student name.\n\nName: ", MaxCharacters);
  305.             }
  306.  
  307.             removeNewlineCharacterIfItExists(studentNames[i]);
  308.  
  309.             return;
  310.         }
  311.     }
  312. }
  313.  
  314. void initialiseStudentNames(Student* students, char studentNames[][MaxCharacters])
  315. {
  316.     students->studentNames = malloc(students->studentsInTheGroupCount * sizeof(char*));
  317.  
  318.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  319.     {
  320.         students->studentNames[i] = strdup(studentNames[i]);
  321.     }
  322. }
  323.  
  324. void freeStudentNames(Student* students)
  325. {
  326.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  327.     {
  328.         free(students->studentNames[i]);
  329.     }
  330.  
  331.     free(students->studentNames);
  332. }
  333.  
  334. void inputFacultyNumbers(Student* students)
  335. {
  336.     printf("Input the faculty numbers of the students:\n\n\n");
  337.  
  338.     char facultyNumbers[MaxStudentsInTheGroupCount][MaxCharacters] = { { '\0' } };
  339.  
  340.     for (unsigned short i = 0; i < students->studentsInTheGroupCount; i++)
  341.     {
  342.         printf("Student %hu: \n", i + 1);
  343.  
  344.         printf("Name: %s\n", students->studentNames[i]);
  345.  
  346.         printf("Faculty number: ");
  347.  
  348.         while (fgets(facultyNumbers[i], MaxCharacters, stdin) == NULL)
  349.         {
  350.             printf("\n\nToo many inputted characters! The max value of characters is %hu. Input a faculty number.\n\nFaculty number: ", MaxCharacters);
  351.         }
  352.  
  353.         removeNewlineCharacterIfItExists(facultyNumbers[i]);
  354.  
  355.         printf("\n\n");
  356.     }
  357.  
  358.     initialiseFacultyNumbers(students, facultyNumbers);
  359. }
  360.  
  361. void inputFacultyNumber(Student* students, char facultyNumbers[][MaxCharacters])
  362. {
  363.     for (unsigned short i = 0; i < students->studentsInTheGroupCount; i++)
  364.     {
  365.         if (!strcmp(facultyNumbers[i], "\0"))
  366.         {
  367.             while (fgets(facultyNumbers[i], MaxCharacters, stdin) == NULL)
  368.             {
  369.                 printf("\n\nToo many inputted characters! The max value of characters is %hu. Input a faculty number.\n\nFaculty number: ", MaxCharacters);
  370.             }
  371.  
  372.             removeNewlineCharacterIfItExists(facultyNumbers[i]);
  373.  
  374.             return;
  375.         }
  376.     }
  377. }
  378.  
  379. void initialiseFacultyNumbers(Student* students, char facultyNumbers[][MaxCharacters])
  380. {
  381.     students->facultyNumbers = malloc(students->studentsInTheGroupCount * sizeof(char*));
  382.  
  383.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  384.     {
  385.         students->facultyNumbers[i] = strdup(facultyNumbers[i]);
  386.     }
  387. }
  388.  
  389. void freeFacultyNumbers(Student* students)
  390. {
  391.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  392.     {
  393.         free(students->facultyNumbers[i]);
  394.     }
  395.  
  396.     free(students->facultyNumbers);
  397. }
  398.  
  399. void inputGrades(Student* students)
  400. {
  401.     printf("Input the students' grades on each subject:\n\n\n");
  402.  
  403.     float grades[MaxStudentsInTheGroupCount][MaxSubjectsCount];
  404.  
  405.     for (unsigned short i = 0; i < students->studentsInTheGroupCount; i++)
  406.     {
  407.         printf("Student %hu: \n", i + 1);
  408.  
  409.         printf("Name: %s\n", students->studentNames[i]);
  410.  
  411.         printf("Faculty number: %s\n", students->facultyNumbers[i]);
  412.  
  413.         for (size_t j = 0; j < students->subjectsCount; j++)
  414.         {
  415.             inputAGrade:
  416.             printf("%s: ", students->subjectNames[j]);
  417.             scanf("%f", &grades[i][j]);
  418.  
  419.             if (!isValidGrade(grades[i][j]))
  420.             {
  421.                 printf("\n\nIvalid grade! Input a new one.\n\n");
  422.  
  423.                 goto inputAGrade;
  424.             }
  425.         }
  426.  
  427.         printf("\n\n");
  428.     }
  429.  
  430.     initialiseGrades(students, grades);
  431. }
  432.  
  433. void inputGrade(Student* students, float grades[][MaxSubjectsCount])
  434. {
  435.     for (unsigned short i = 0; i < students->studentsInTheGroupCount; i++)
  436.     {
  437.         for (size_t j = 0; j < students->subjectsCount; j++)
  438.         {
  439.             if (grades[i][j] == 0.0f)
  440.             {
  441.                 inputAGrade:
  442.                 scanf("%f", &grades[i][j]);
  443.  
  444.                 if (!isValidGrade(grades[i][j]))
  445.                 {
  446.                     printf("\n\nIvalid grade! Input a new one.\n\n%s: ", students->subjectNames[j]);
  447.  
  448.                     goto inputAGrade;
  449.                 }
  450.  
  451.                 return;
  452.             }
  453.         }
  454.     }
  455. }
  456.  
  457. bool isValidGrade(float grade)
  458. {
  459.     return (grade >= MinGrade) && (grade <= MaxGrade);
  460. }
  461.  
  462. void initialiseGrades(Student* students, float grades[][MaxSubjectsCount])
  463. {
  464.     students->grades = malloc(students->studentsInTheGroupCount * sizeof(float*));
  465.  
  466.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  467.     {
  468.         students->grades[i] = malloc(students->subjectsCount * sizeof(float));
  469.  
  470.         memcpy(students->grades[i], grades[i], students->subjectsCount * sizeof(float));
  471.     }
  472. }
  473.  
  474. void freeGrades(Student* students)
  475. {
  476.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  477.     {
  478.         free(students->grades[i]);
  479.     }
  480.  
  481.     free(students->grades);
  482. }
  483.  
  484. void inputStudentInformation(Student* students)
  485. {
  486.     printf("Input information for each student in the group:\n\n\n");
  487.  
  488.     char studentNames[MaxStudentsInTheGroupCount][MaxCharacters] = { { '\0' } };
  489.  
  490.     char facultyNumbers[MaxStudentsInTheGroupCount][MaxCharacters] = { { '\0' } };
  491.  
  492.     float grades[MaxStudentsInTheGroupCount][MaxSubjectsCount] = { { 0.0f } };
  493.  
  494.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  495.     {
  496.         printf("Student %llu:\n\n", i + 1);
  497.  
  498.         printf("Name: ");
  499.         inputStudentName(students, studentNames);
  500.  
  501.         printf("Faculty number: ");
  502.         inputFacultyNumber(students, facultyNumbers);
  503.  
  504.         for (size_t j = 0; j < students->subjectsCount; j++)
  505.         {
  506.             printf("%s: ", students->subjectNames[j]);
  507.             inputGrade(students, grades);
  508.         }
  509.  
  510.         printf("\n\n");
  511.  
  512.         clearTheInputBufferIfNeededAndTheScreen(true, false);
  513.     }
  514.  
  515.     initialiseStudentNames(students, studentNames);
  516.  
  517.     initialiseFacultyNumbers(students, facultyNumbers);
  518.  
  519.     initialiseGrades(students, grades);
  520. }
  521.  
  522. void printStudentInformation(Student* students)
  523. {
  524.     clearTheInputBufferIfNeededAndTheScreen(false, true);
  525.  
  526.     printf("Group information:\n\n\n");
  527.  
  528.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  529.     {
  530.         printf("Student %llu:\n\n", i + 1);
  531.  
  532.         printf("Name: %s\n", students->studentNames[i]);
  533.  
  534.         printf("Faculty number: %s\n", students->facultyNumbers[i]);
  535.  
  536.         for (size_t j = 0; j < students->subjectsCount; j++)
  537.         {
  538.             printf("%s: %.2f\n", students->subjectNames[j], students->grades[i][j]);
  539.         }
  540.  
  541.         printf("\n\n");
  542.     }
  543. }
  544.  
  545. void initialiseStructMembers(Student* students)
  546. {
  547.     inputStudentsInTheGroupCount(students);
  548.  
  549.     clearTheInputBufferIfNeededAndTheScreen(true, true);
  550.  
  551.     inputSubjectsCount(students);
  552.    
  553.     clearTheInputBufferIfNeededAndTheScreen(true, true);
  554.  
  555.     inputSubjectNames(students);
  556.  
  557.     clearTheInputBufferIfNeededAndTheScreen(false, true);
  558.  
  559.     if (false)
  560.     {
  561.         inputStudentNames(students);
  562.  
  563.         clearTheInputBufferIfNeededAndTheScreen(false, true);
  564.  
  565.         inputFacultyNumbers(students);
  566.  
  567.         clearTheInputBufferIfNeededAndTheScreen(false, true);
  568.  
  569.         inputGrades(students);
  570.     }
  571.    
  572.     else
  573.     {
  574.         inputStudentInformation(students);
  575.     }
  576. }
  577.  
  578. void freeStructMembers(Student* students)
  579. {
  580.     freeSubjectNames(students);
  581.    
  582.     freeStudentNames(students);
  583.  
  584.     freeFacultyNumbers(students);
  585.  
  586.     freeGrades(students);
  587. }
  588.  
  589. void removeNewlineCharacterIfItExists(char* string)
  590. {
  591.     size_t stringLength = strlen(string);
  592.  
  593.     if ( (stringLength > 0) && (string[stringLength - 1] == '\n') )
  594.     {
  595.         string[stringLength - 1] = '\0';
  596.     }
  597. }
  598.  
  599. // Function, which waits the user to press the "ENTER / RETURN" key
  600.  
  601. void pressTheEnterKeyToContinue()
  602. {
  603.     printf("\n\n\nPress \"ENTER\" to go back to the Main Menu");
  604.  
  605.     while (_getch() != 13); // "\r" - The "ENTER / RETURN" key
  606. }
  607.  
  608. // Function, which decides to either turn on or turn off the cursor by giving a bool value either "true / 1" or "false / 0"
  609.  
  610. void isCursorVisible(bool isVisible)
  611. {
  612.     HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
  613.  
  614.     CONSOLE_CURSOR_INFO cursorInfo;
  615.     GetConsoleCursorInfo(consoleHandle, &cursorInfo);
  616.  
  617.     cursorInfo.bVisible = isVisible;
  618.     SetConsoleCursorInfo(consoleHandle, &cursorInfo);
  619. }
  620.  
  621. // Function, which clears the input buffer from the newline character and clears the screen
  622.  
  623. void clearTheInputBufferIfNeededAndTheScreen(bool clearBuffer, bool clearScreen)
  624. {
  625.     if (clearBuffer)
  626.     {
  627.         char character = getchar();
  628.  
  629.         while ( (character != '\n') && (character != EOF) );
  630.     }
  631.  
  632.     if (clearScreen)
  633.     {
  634.         system("cls");
  635.     }
  636. }
  637.  
  638. void mainMenu(Student* students)
  639. {
  640.     char* options[] = { { "1. Search for a student" }, { "2. Option 2" }, { "3. Option 3" }, { "4. Exit" } };
  641.  
  642.     unsigned short totalOptions = sizeof(options) / sizeof(options[0]);
  643.  
  644.     unsigned short selectedOption = 1;
  645.  
  646.     bool isExit = false;
  647.  
  648.     while (!isExit)
  649.     {
  650.         system("cls");
  651.  
  652.         displayMenu(options, selectedOption, totalOptions);
  653.  
  654.         menuControls(students, &selectedOption, totalOptions, &isExit);
  655.     }
  656. }
  657.  
  658. void displayMenu(char* options[], unsigned short selectedOption, unsigned short totalOptions)
  659. {
  660.     printf("          Menu:\n\n");
  661.  
  662.     for (size_t i = 0; i < totalOptions; i++)
  663.     {
  664.         printf("%s%s\n", (selectedOption == (i + 1)) ? "--> " : "    ", options[i]);
  665.     }
  666. }
  667.  
  668. void menuControls(Student* students, unsigned short* selectedOption, unsigned short totalOptions, bool* isExit)
  669. {
  670.     char key = getch();
  671.  
  672.     switch (key)
  673.     {
  674.         case 'W': case 'w': case 72: // Up arrow key
  675.         *selectedOption = (*selectedOption > 1) ? *selectedOption - 1 : totalOptions; break;
  676.  
  677.         case 'S': case 's': case 80: // Down arrow key
  678.         *selectedOption = (*selectedOption < totalOptions) ? *selectedOption + 1 : 1; break;
  679.  
  680.         case 13: // Enter key
  681.         switch (*selectedOption)
  682.         {
  683.             case 1: searchForAStudent(students); pressTheEnterKeyToContinue(); break;
  684.  
  685.             case 2: break;
  686.  
  687.             case 3: break;
  688.  
  689.             case 4: freeStructMembers(students); *isExit = true;
  690.         }
  691.  
  692.         break;
  693.     }
  694. }
  695.  
  696. void searchForAStudent(Student* students)
  697. {
  698.     clearTheInputBufferIfNeededAndTheScreen(false, true);
  699.  
  700.     char studentName[MaxCharacters];
  701.  
  702.     unsigned short indexOfTheStudent = 0;
  703.  
  704.     inputAStudentName:
  705.  
  706.     printf("Input a name of a student to search: ");
  707.  
  708.     while (fgets(studentName, MaxCharacters, stdin) == NULL)
  709.     {
  710.         printf("\n\nToo many inputted characters! The max value of characters is %hu. Input a new name.\n\nInput a name of a student to search: ", MaxCharacters);
  711.     }
  712.  
  713.     removeNewlineCharacterIfItExists(studentName);
  714.  
  715.     clearTheInputBufferIfNeededAndTheScreen(false, true);
  716.  
  717.     if (!isStudentPresentInTheGroup(students, studentName, &indexOfTheStudent))
  718.     {
  719.         printf("There's no student with this name in this group.\n\n\n");
  720.  
  721.         goto inputAStudentName;
  722.     }
  723.  
  724.     printf("Student with this name has been found.\n\n\n");
  725.  
  726.     printInformationAboutTheStudent(students, indexOfTheStudent);
  727. }
  728.  
  729. bool isStudentPresentInTheGroup(Student* students, char studentName[], unsigned short* indexOfTheStudent)
  730. {
  731.     for (size_t i = 0; i < students->studentsInTheGroupCount; i++)
  732.     {
  733.         if (!strcmp(students->studentNames[i], studentName))
  734.         {
  735.             *indexOfTheStudent = i;
  736.  
  737.             return true;
  738.         }
  739.     }
  740.  
  741.     return false;
  742. }
  743.  
  744. void printInformationAboutTheStudent(Student* students, unsigned short indexOfTheStudent)
  745. {
  746.     printf("Student %llu:\n\n", indexOfTheStudent + 1);
  747.  
  748.     printf("Name: %s\n", students->studentNames[indexOfTheStudent]);
  749.  
  750.     printf("Faculty number: %s\n", students->facultyNumbers[indexOfTheStudent]);
  751.  
  752.     for (size_t j = 0; j < students->subjectsCount; j++)
  753.     {
  754.         printf("%s: %.2f\n", students->subjectNames[j], students->grades[indexOfTheStudent][j]);
  755.     }
  756. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement