Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma clang diagnostic push
- #pragma ide diagnostic ignored "cert-err34-c"
- #include <stdio.h>
- #include <string.h>
- #include <locale.h>
- #include <windows.h>
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wunknown-pragmas"
- #pragma clang diagnostic ignored "-Wformat"
- typedef struct Student {
- char name [256];
- char group[50];
- int ses [5];
- }TStudent;
- void inputStudentInfo(TStudent* student, int studentNumber);
- void sortList(TStudent* student, int listSize);
- void showStudentInfo(TStudent* student, int studentNumber);
- int main() {
- setlocale(LC_ALL, "Rus");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- TStudent student [10];
- for (int i = 0; i < 10; ++i) {
- inputStudentInfo(&student[i], i);
- }
- sortList(student, 10);
- for (int j = 0; j < 10; ++j) {
- showStudentInfo(&student[j], j);
- }
- }
- void inputStudentInfo(TStudent* student, int studentNumber) {
- printf(" Введите ФИО %d студента: ", studentNumber + 1);
- scanf("%s", &student->name);
- printf(" Введите номер группы для %d студента: ", studentNumber + 1);
- scanf("%s", &student->group);
- printf("Введите оценки студента %s : ", student->name);
- for (int j = 0; j < 5; ++j) {
- scanf("%d", &student->ses[j]);
- }
- }
- void sortList(TStudent* student, int listSize) {
- for (int j = 0; j < listSize; ++j) {
- for (int i = 0; i < listSize - 1; ++i) {
- if(strcmp(student[i].name,student[i+1].name)>0){
- TStudent temp;
- temp = student[i];
- student[i] = student[i + 1];
- student[i + 1] = temp;
- }
- }
- }
- }
- void showStudentInfo(TStudent* student, int studentNumber) {
- int status = 0;
- for (int i = 0; i < 5; ++i) {
- if (student->ses[i] == 2) {
- printf("\n%d. %s в группе %s имеет двойку.\n", studentNumber + 1, student->name, student->group);
- status = 1;
- break;
- }
- }
- if (status == 0) {
- printf("У студентов нет двоек.");
- }
- printf("\n");
- }
- #pragma clang diagnostic pop
- #pragma clang diagnostic pop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement