# include & ltstdio.h & gt
# include & ltconio.h & gt
# include & ltstdlib.h & gt
# include & ltstring.h & gt
#定義最大80
void輸入();
void sort();
void顯示();
void insert();
void del();
void平均值();
void find();;
void read();;
void平均值();
void modify();
int now _ no = 0;
結構學生
{
int號;
char name[20];
char sex[4];
float score 1;
浮動分數2;
浮動分數3;
浮點排序;
浮動大街;
浮動總和;
};
Voidhaverage ()/*求平均值*/
{
int I;
for(I = 0;我& lt現在_沒有;i++)
{
斯圖[我]。sum = stu[I]. score 1+stu[I]. score 2+stu[I]. score 3;
斯圖[我]。ave=stu[i]。sum/3;
}
}
struct student stu[MAX],* p;
Main()/*主函數*/
{
int as
start:printf(" \ n \ t \ t \ t歡迎使用學生成績管理系統\ n ");
/*接下來是功能選擇模塊*/
做
{
Printf ("\n \ t \ t \ t1。輸入學生信息\ n \ t \ t \ t2。顯示學生信息\ n \ t \ t \ t3。分級信息\ n \ t \ t \。
Printf ("\ t \ t \ t \ tSelect函數選項:");
fflush(stdin);
scanf("%d ",& ampas);
開關(組件)
{
案例1:系統(" cls ");input();打破;
案例二:系統(“cls”);顯示();打破;
案例三:系統(“cls”);sort();打破;
案例四:系統(“cls”);insert();打破;
案例五:系統(“cls”);del();打破;
案例6:系統(“cls”);modify();打破;
案例7:系統(“cls”);find();打破;;
案例八:系統(“退出”);退出(0);
默認值:system(" cls ");轉到開始;
}
} while(1);
/*這是功能選擇的結束*/
}
Void input()/*原始數據輸入模塊*/
{
int I = 0;
char ch
做
{
Printf ("\ t \ t \ t1。輸入學生信息\n輸入%d名學生的信息\ n ",I+1);
printf(" \ n輸入學號:");
scanf("%d ",& amp斯圖[我]。否);
fflush(stdin);
printf(" \ n輸入學生姓名:");
fflush(stdin);
獲取(stu[i]。姓名);
printf(" \ n輸入學生性別:");
fflush(stdin);
獲取(stu[i]。性);
printf(" \ n輸入學生成績1:");
fflush(stdin);
scanf("%f ",& ampstu[I]. score 1);
printf(" \ n輸入學生年級2:");
fflush(stdin);
scanf("%f ",& ampstu[I]. score 2);
printf(" \ n輸入學生三年級:");
fflush(stdin);
scanf("%f ",& ampstu[I]. score 3);
printf(" \ n \ n ");
i++;
now _ no = I;
Printf("要繼續打字嗎?(Y/N)");
fflush(stdin);
ch = getch();
系統(“cls”);
}
而(ch!= ' n ' & amp& ampch!= ' N ');
系統(“cls”);
}
Void sort()/*排序數據函數*/
{
結構學生溫度;
int i,j;
平均值();
for(I = 1;我& lt現在_沒有;i++)
{
for(j = 1;j & lt= now _ no-I;j++)
{
if(stu[j-1]。ave & lt斯圖[j]。ave)
{
temp = stu[j];
stu[j]= stu[j-1];
stu[j-1]= temp;
}
}
}
}
Void display()/*顯示數據函數*/
{
int I;
char as
平均值();
做
{
printf(" \ t \ t \ t類信息列表\ n ");
printf(" \ t沒有。\ tName \ tSex \ ts core 1 \ ts core 2 \ ts core 3 \ t average \ n ");
for(I = 0;我& lt現在_不& amp& amp斯圖[我]。名稱[0];i++)printf(" \ t % d \ t % s \ t % s \ t % . 2f \ t % . 2f \ t % . 2f \ t % . 2f \ n ",stu[i].不,斯圖[我]。姓名,斯圖[我]。性,斯圖[我].分數1,斯圖[我].分數2,斯圖[我].分數3,斯圖[我].ave);
printf(" \ t \ t按任意鍵返回主菜單。);
fflush(stdin);
as = getch();
}
而(!as);
系統(“cls”);
}
Void insert()/*插入數據函數*/
{
char ch
做
{
printf(" \ n \ t \ t輸入新插入的學生團隊的信息\ n ");
printf(" \ n輸入學號:");
scanf("%d ",& amp斯圖【現在_沒有】。否);
fflush(stdin);
printf(" \ n輸入學生姓名:");
fflush(stdin);
獲取(stu[now_no]。姓名);
printf(" \ n輸入學生性別:");
fflush(stdin);
獲取(stu[now_no]。性);
printf(" \ n輸入學生成績1:");
fflush(stdin);
scanf("%f ",& ampstu[now _ no]. score 1);
printf(" \ n輸入學生年級2:");
fflush(stdin);
scanf("%f ",& ampstu[now _ no]. score 2);
printf(" \ n輸入學生三年級:");
fflush(stdin);
scanf("%f ",& ampstu[now _ no]. score 3);
printf(" \ n \ n ");
現在_否=現在_否+1;
sort();
Printf("要繼續打字嗎?(Y/N)");
fflush(stdin);
ch = getch();
系統(“cls”);
}
而(ch!= ' n ' & amp& ampch!= ' N ');
}
Void del()/*刪除數據函數*/
{
int inum,I,j;
Printf("輸入要刪除的學生編號:");
fflush(stdin);
scanf("%d ",& ampinum);
for(I = 0;我& lt現在_沒有;i++)
{
如果(斯圖[我]。no==inum)
{
if(I = = now _ no)now _ no-= 1;
其他
{
stu[I]= stu[now _ no-1];
now _ no-= 1;
}
sort();
打破;
}
}
系統(“cls”);
}
Void find()/*查詢函數*/
{
int I;
char string[20],as;
做
{
Printf("輸入要查詢的學生姓名:");
fflush(stdin);
gets(str);
for(I = 0;我& lt現在_沒有;i++)
如果(!strcmp(stu[i].名稱,字符串))
{
printf(" \ t沒有。\ tName \ tSex \ ts core 1 \ ts core 2 \ ts core 3 \ t average \ n ");
printf(" \ t % d \ t % s \ t % s \ t % . 2f \ t % . 2f \ t % . 2f \ t % . 2f \ n ",stu[i]。不,斯圖[我]。姓名,斯圖[我]。性,斯圖[我].分數1,斯圖[我].分數2,斯圖[我].分數3,斯圖[我].ave);
}
printf(" \ t \ t按任意鍵返回主菜單。);
fflush(stdin);
as = getch();
}
而(!as);
系統(“cls”);
}
Void modify()/*修改數據函數*/
{
int I;
char string[20],as;
Printf("輸入要修改的學生姓名:");
fflush(stdin);
gets(str);
for(I = 0;我& lt現在_沒有;i++)
如果(!strcmp(stu[i].名稱,字符串))
{
系統(“cls”);
printf(" \ n \ t \ t輸入並修改學生信息\ n ");
printf(" \ n輸入學號:");
fflush(stdin);
scanf("%d ",& amp斯圖[我]。否);
printf(" \ n輸入學生性別:");
fflush(stdin);
獲取(stu[i]。性);
printf(" \ n輸入學生成績1:");
fflush(stdin);
scanf("%f ",& ampstu[I]. score 1);
printf(" \ n輸入學生年級2:");
fflush(stdin);
scanf("%f ",& ampstu[I]. score 2);
printf(" \ n輸入學生三年級:");
fflush(stdin);
scanf("%f ",& ampstu[I]. score 3);
printf(" \ n \ n ");
sort();
打破;
}
系統(“cls”);
}