Good day!

Tell me what the error is, the compiler swears

#include <vcl.h> #include <stdio.h> #pragma hdrstop /* 1.Упорядочить список студентов по среднему баллу и вывести весь список. 2.Вывести анкетные данные студентов, получивших по предмету физика оценку "неудовлетворительно" */ #pragma argsused const int N = 4; // count students struct stud { char name[15]; char name2[15]; int dayborn; int month; int yearborn; char group[10]; int ball[5]; float SredBall; int physicsBall; int CountEx; }; s[N], tmp; int main(int argc, char *argv[]) { int i, j, k, m; for (i = 0; i < N; i++) { printf("Enter first name of %dst student ", i + 1); scanf("%15s", &s[i].name); printf("Enter second name "); scanf("%15s", &s[i].name2); printf("Enter day of borning "); scanf("%10d", &s[i].dayborn); printf("Enter month of borning "); scanf("%10d", &s[i].month); printf("Enter year of borning "); scanf("%10d", &s[i].yearborn); printf("Enter its group "); scanf("%10s", &s[i].group); printf("Vvedite kolichestvo predmetov "); scanf("%1d", &m); for (j = 0; j < m; j++) { printf("Enter its ball for %dst predmet ", j + 1); scanf("%3d", &s[i].ball[j]); } } for (i = 0; i < N; i++) { int sum = 0; for (j = 0; j < m; j++) { sum = sum + s[i].ball[j]; } s[i].SredBall = (float)sum / m; } for (i = 0; i < N; i++) for (j = i + 1; j < N; j++) if (s[i].SredBall < s[j].SredBall) { tmp = s[i]; s[i] = s[j]; s[j] = tmp; } printf("%-26s %-13s %-8s %s", "Name", "Date", "group", "SredBall\n"); for (i = 0; i < N; i++) printf("%-10s %-15s %02d.%02d.%-7d %-8s %.2f\n", s[i].name, s[i].name2, s[i].dayborn, s[i].month, s[i].yearborn, s[i].group, s[i].SredBall); int k, i, j; k = 0; for (i = 0; i < n; i++) { printf("Enter quantity of exams\n"); scanf("%d", &s[i].CountEx); getchar(); printf("Enter his ball on physics\n"); scanf("%d", &s[i].physics_ball); printf("Enter his balls on other subjects\n"); for (j = 0; j < s[i].CountEx - 1; j++) { printf("Enter his %d-st ball\n", j + 1); scanf("%d", &s[i].ball[j]); } } int r = 0; while (r < 40) { printf("\n"); r++; } printf("%-26s %-13s %-8s %s", "Name", "Date", "Ball on physics", "Other balls\n"); for (i = 0; i < N; i++) printf("%-10s %-15s %02d.%02d.%-7d %-8s %.2f\n", s[i].name, s[i].name2, s[i].dayborn, s[i].month, s[i].yearborn, s[i].group, s[i].physics_ball); printf("\n"); printf("Students whose ball on physics is hasn't handed over:"); for (i = 0; i < n; i++) if (s[i].physics_ball < 3) printf("%-8s%-12s", s[i].name, s[i].name2); else k += 1; if (k == n) printf(" None"); getchar(); getchar(); return 0; } 

In the beginning 2 tasks are written. First, task code 1 was written, and it worked perfectly. But now I want to combine 1 and 2 tasks, so that I would list the entire list of students, and below 2 tables (1 and 2 tasks). 2 was written separately, but when combining the error.

  • @smthelse, The code should be formatted (button 101010), and the label should reflect the programming language, otherwise the questions will be deleted. - Nicolas Chabanovsky

1 answer 1

Try this, it should work:

 #include <stdio.h> #pragma hdrstop const int N = 4; // count students struct stud { char name[15]; char name2[15]; int dayborn; int month; int yearborn; char group[10]; int ball[5]; float SredBall; int physicsBall; int CountEx; } s[N], tmp; int main(int argc, char* argv[]) { int i, j, k, m; for (i = 0; i < N; i++) { printf("Enter first name of %dst student ", i + 1); scanf("%15s", (char *) &s[i].name); printf("Enter second name "); scanf("%15s", (char *) &s[i].name2); printf("Enter day of borning "); scanf("%10d", &s[i].dayborn); printf("Enter month of borning "); scanf("%10d", &s[i].month); printf("Enter year of borning "); scanf("%10d", &s[i].yearborn); printf("Enter its group "); scanf("%10s", (char *) &s[i].group); printf("Vvedite kolichestvo predmetov "); scanf("%1d", &m); for (j = 0; j < m; j++) { printf("Enter its ball for %dst predmet ", j + 1); scanf("%3d", &s[i].ball[j]); } } for (i = 0; i < N; i++) { int sum = 0; for (j = 0; j < m; j++) { sum = sum + s[i].ball[j]; } s[i].SredBall = (float) sum / m; } for (i = 0; i < N; i++) for (j = i + 1; j < N; j++) if (s[i].SredBall < s[j].SredBall) { tmp = s[i]; s[i] = s[j]; s[j] = tmp; } printf("%-26s %-13s %-8s %s", "Name", "Date", "group", "SredBall\n"); for (i = 0; i < N; i++) printf("%-10s %-15s %02d.%02d.%-7d %-8s %.2f\n", s[i].name, s[i].name2, s[i].dayborn, s[i].month, s[i].yearborn, s[i].group, s[i].SredBall); k = 0; for (i = 0; i < N; i++) { printf("Enter quantity of examsn"); scanf("%d", &s[i].CountEx); getchar(); printf("Enter his ball on physics\n"); scanf("%d", &s[i].physicsBall); printf("Enter his balls on other subjects\n"); for (j = 0; j < s[i].CountEx - 1; j++) { printf("Enter his %d-st ball\n", j + 1); scanf("%d", &s[i].ball[j]); } } int r = 0; while (r < 40) { printf("n"); r++; } printf("%-26s %-13s %-8s %s", "Name", "Date", "Ball on physics", "Other ballsn"); for (i = 0; i < N; i++) printf("%-10s %-15s %02d.%02d.%-7d %-8s %.2fn", s[i].name, s[i].name2, s[i].dayborn, s[i].month, s[i].yearborn, s[i].group, s[i].physicsBall); printf("n"); printf("Students whose ball on physics is hasn't handed over:"); for (i = 0; i < N; i++) if (s[i].physicsBall < 3) printf("%-8s%-12s", s[i].name, s[i].name2); else k += 1; if (k == N) printf(" None"); getchar(); getchar(); return 0; } 
  • thanks, works - smthelse