ADD file via upload

main
pecp45i32 17 hours ago
parent 856fc56261
commit 79ca00f2c7

@ -0,0 +1,106 @@
#include <stdio.h>
#define COL 6
#define GRADEBINGIN 2
int studentMember = 0;
double storeInformation[100][COL];
void inputStudentInformation(double store[][COL])
{
double* p;
int i = 0, j = 0;
while (1) {
p = &store[i][j];
double temp;
scanf("%lf", &temp);
*p = temp;
j++;
if (j == COL - 1) {
*(p + 1) = 0;
printf("One student's information has been, input 0 or 1 to quit or continue.\n");
int ch;
scanf("%d", &ch);
if (ch == 0) { break; }
else if (ch == 1)
{
j = 0;
i++;
studentMember++;
}
else {
printf("WRONG INPUT,aoto quit\n");
break;
}
}
}
}
double sumScore(double store[][COL], int n) {
double sum = 0;
for (int i = GRADEBINGIN; i < COL - 1; i++) {
sum += store[n][i];
}
return sum;
}
void printStudentOriginalScore(double store[][COL])
{
for (int i = 0; i <= studentMember; i++) {
printf("%5d %d %.1f %.1f %.1f %.1f %s\n", (int)store[i][0], (int)store[i][1], store[i][2], store[i][3], store[i][4], sumScore(store, i), store[i][6] == 1? "":"inserted");
}
}
void printstep2(double store[][COL]) {
for (int i = 0; i <= studentMember; i++) {
printf("%5d,%.1f,%.1f\n", (int)storeInformation[i][0], sumScore(storeInformation, i), sumScore(storeInformation, i) / 3);
}
}
void insertedNew() {
printf("The new student information\n");
studentMember++;
double* p;
for (int i = 0; i < COL - 1; i++) {
p = &storeInformation[studentMember][i];
double temp = 0;
scanf("%lf", &temp);
*p = temp;
}
*(p + 1) = 1;
}
void manage()
{
printf(" 1.Input\n");
printf(" 2.Output\n");
printf(" 3.Order\n");
printf(" 4.Quit\n");
char keywords;
keywords = getchar();
switch (keywords) {
case 'i':
printf("Please input info of the three students\n");
inputStudentInformation(storeInformation);
break;
case 'o':
printf("You are trying to Output info\n");
break;
case 'm':
printf("You are trying to Make things ordered\n");
break;
case 'q':
printf("You are about to Quit\n");
break;
default:
printf("Wrong input\n");
break;
}
}
int main()
{
manage();
insertedNew();
printStudentOriginalScore(storeInformation);
return 0;
}
Loading…
Cancel
Save