阅读量:0
#include <stdio.h>
#define MAX_STUDENTS 100
struct Student { int id; char name[50]; float score; };
int main() { struct Student students[MAX_STUDENTS]; int num_students = 0;
printf("Enter the number of students: "); scanf("%d", &num_students); if (num_students > MAX_STUDENTS) { printf("Exceeds maximum number of students.\n"); return 1; } for (int i = 0; i < num_students; i++) { printf("Enter student ID: "); scanf("%d", &students[i].id); printf("Enter student name: "); scanf("%s", students[i].name); printf("Enter student score: "); scanf("%f", &students[i].score); } printf("\nStudent Information:\n"); printf("ID\tName\tScore\n"); for (int i = 0; i < num_students; i++) { printf("%d\t%s\t%.2f\n", students[i].id, students[i].name, students[i].score); } return 0;
}