|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#define MAX_STUDENTS 100
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
int id;
|
|
|
|
|
char name[50];
|
|
|
|
|
float gaoshu;
|
|
|
|
|
float wuli;
|
|
|
|
|
float yingyu;
|
|
|
|
|
} Student;
|
|
|
|
|
|
|
|
|
|
Student students[MAX_STUDENTS];
|
|
|
|
|
int studentCount = 0;
|
|
|
|
|
|
|
|
|
|
void addStudent() {
|
|
|
|
|
printf("You are trying to Input info\n");
|
|
|
|
|
if (studentCount >= MAX_STUDENTS) {
|
|
|
|
|
printf("Cannot add more students. Maximum limit reached.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Student newStudent;
|
|
|
|
|
printf("Enter ID: ");
|
|
|
|
|
scanf("%d", &newStudent.id);
|
|
|
|
|
printf("Enter Name: ");
|
|
|
|
|
scanf("%s", newStudent.name);
|
|
|
|
|
printf("Enter <20><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>: ");
|
|
|
|
|
scanf("%f", &newStudent.gaoshu);
|
|
|
|
|
printf("Enter <20><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>: ");
|
|
|
|
|
scanf("%f", &newStudent.wuli);
|
|
|
|
|
printf("Enter Ӣ<><D3A2><EFBFBD>ɼ<EFBFBD>: ");
|
|
|
|
|
scanf("%f", &newStudent.yingyu);
|
|
|
|
|
|
|
|
|
|
students[studentCount++] = newStudent;
|
|
|
|
|
printf("Student added successfully!\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deleteStudent() {
|
|
|
|
|
int id;
|
|
|
|
|
printf("You are trying to Output info\n");
|
|
|
|
|
printf("Enter ID of the student to delete: ");
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < studentCount; i++) {
|
|
|
|
|
if (students[i].id == id) {
|
|
|
|
|
for (int j = i; j < studentCount - 1; j++) {
|
|
|
|
|
students[j] = students[j + 1];
|
|
|
|
|
}
|
|
|
|
|
studentCount--;
|
|
|
|
|
printf("Student deleted successfully!\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Student not found!\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void displayStudents() {
|
|
|
|
|
printf("You are trying to Make things ordered\n");
|
|
|
|
|
if (studentCount == 0) {
|
|
|
|
|
printf("No students to display.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("ID\tName\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\tӢ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>\t<EFBFBD>ܳɼ<EFBFBD>\n");
|
|
|
|
|
for (int i = 0; i < studentCount; i++) {
|
|
|
|
|
printf("%d\t%s\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\n", students[i].id, students[i].name, students[i].gaoshu,students[i].wuli,students[i].yingyu,students[i].gaoshu+students[i].wuli+students[i].yingyu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int choice;
|
|
|
|
|
int running = 1; // <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
|
|
|
|
|
|
|
|
|
while (running) { printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>4ʹ<EFBFBD>ö<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf(" 1. Input\n");
|
|
|
|
|
printf(" 2. Output\n");
|
|
|
|
|
printf(" 3. Order\n");
|
|
|
|
|
printf(" 4. Quit\n");
|
|
|
|
|
printf("Enter your choice: ");
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
|
|
|
|
|
switch (choice) {
|
|
|
|
|
case 1:
|
|
|
|
|
addStudent();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
deleteStudent();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
displayStudents();
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
running = 0; // <20><><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD>˳<EFBFBD>ѭ<EFBFBD><D1AD>
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("Wrong input.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|