Home > Back-end >  C language for beginners modular programming for the great god completion code
C language for beginners modular programming for the great god completion code

Time:10-06

/* * * * * * * * * * * * * * * * * * * header file * * * * * * * * * * * * * * * * * * * * */
#include
#include
#include
/* * * * * * * * * * * * * * * * * * * constants * * * * * * * * * * * * * * * * * * * * */
# define N 3
# define MAX 100
/* * * * * * * * * * * * * * * * * * * struct * * * * * * * * * * * * * * * * * * * * */
Struct student
{
Char num [10].
Char name [15].
Float score [N].
Float sum;
Float aveerage;
};
/* * * * * * * * * * * * * * * * * * * global variables to * * * * * * * * * * * * * * * * * * * * */
Int count;
Struct student stud (MAX);

/* * * * * * * * * * * * * * * * * * * function declarations * * * * * * * * * * * * * * * * * * * * */
Void printMenu ();
Void input ();
Void the output ();
Void computer ();
Void the find ();
Void the sort ();
/* * * * * * * * * * * * * * * * * * * the main function * * * * * * * * * * * * * * * * * * * * */
Int main ()
{
Int choose;
count=0;
While (1)
{
PrintMenu ();
The scanf (" % d ", & amp; Choose);
Witch (choose)
{
Case 1: input (); break;
Case 2: the find (); break;
Case 3: computer (); break;
Case 4: the output (); break;
Case 5: exit (0);
}
Printf (" \ n \ n ");
}
Return 0;
}
/* * * * * * * * * * * * * * * * * * * menu function * * * * * * * * * * * * * * * * * * * * */
Void printMenu ()
{
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" | | students management system \ n ");
Printf (" | 1... Achievements recorded | \ n ");
Printf (" | 2... Results query (student number or name) | \ n ");
Printf (" | 3... Performance statistics (gpa) | \ n ");
Printf (" | 4... Performance ranking | \ n ");
Printf (" | 5... Exit system | \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" \ n \ n ");
Printf (" please enter your want to do ");
}
/* * * * * * * * * * * * * * * * * * * input function * * * * * * * * * * * * * * * * * * * * */
Void input ()
{
Int n, I;
Printf (" please input to input the number of the students: ");
The scanf (" % d ", & amp; N);
for (i=0; i{
Printf (" input the first % d student information \ n ", I + 1);
Printf (" student number: ");
The scanf (" % s ", stud [I] num);
Printf (" name: ");
The scanf (" % s ", stud [I] name);
Printf (" grade 1: ");
The scanf (" % f ", & amp; Stud [I] score [0]);
Printf (" grade 2: ");
The scanf (" % f ", & amp; Stud [I] score [1]);
Printf (" grade 3: ");
The scanf (" % f ", & amp; Stud [I] score [2]);
}
The count=n;

}

/* * * * * * * * * * * * * * * * * * * output function * * * * * * * * * * * * * * * * * * * * */
Void the output ()
{
int i;
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" | student id name | | | grade 1 season 2 | 3 | total points scored an average | | \ n ");
for(i=0; i{
Printf (" 6 s | 6 s | | % % % % 5.1 f | 5.1 5.1 f | | f % % 5.1 f | % 5.1 f | \ n ",
Stud [I]. Num, stud [I]. Name, stud [I] score [0], stud [I] score [1], the stud [I] score [2],
Stud [I]. Sum, stud [I] aveerage);
}
}
/* * * * * * * * * * * * * * * * * * * query function * * * * * * * * * * * * * * * * * * * * */
Void the find ()
{

}
/* * * * * * * * * * * * * * * * * * * statistics function * * * * * * * * * * * * * * * * * * * * */
Void computer ()
{

}
/* * * * * * * * * * * * * * * * * * * sort function * * * * * * * * * * * * * * * * * * * * */
Void the sort ()
{

}
  • Related