C語言不用鏈表完成學生管理系統(tǒng)(完整代碼)
1.課程設計目的
1.更好的理解c語言的相關實現(xiàn)內容,對于c語言的理解得到更好的幫助。
2.實現(xiàn)更方便快捷的應用。
2.基本要求
(1)、1.每組完成1個題目的設計;每人獨立完成該題目的一個功能模塊的實現(xiàn),并將課程設計報告打印、裝訂提交。
(2).使用標準C語言編制程序,源代碼必須采用鋸齒型書寫格式,必須上機調試通過。運行界面友好,易于操作。(3).輸出要求:
1)
應用程序正常運行后,要在屏幕上顯示一個文字菜單;2)
要求用戶輸入數(shù)據(jù)時,要給出清晰、明確的提示信息,包括輸入的數(shù)據(jù)內容、格式等;3)為各項操作功能設計一個菜單,應用程序運行后,先顯示這個菜單,然后用戶通過菜單項選擇希望進行的操作項目。
(4).必須實現(xiàn)所要求的全部功能。(5).課程設計要求獨立完成,不得抄襲。若發(fā)現(xiàn)抄襲行為,則成績一律記零分。
3.任務完成情況
1.可以通過程序實現(xiàn)學生信息的增加刪除顯示查找以及修改功能。
2.通過非鏈表的方式運用結構體的方法編寫程序。
4.設計報告
4.1需求分析
4.1.1用戶需求分析
(1)、可以快速度的找出輸入的學生的所有信息。 (2)、可以精確的找出某個學生的所有信息。 (3)、需要準確的修改某個學生的成績。
4.2概要設計
1.增加信息。
2.顯示信息。
3.查找信息。
4.刪除信息。
5.修改信息。
4.3詳細設計
4.3.1程序流程圖

4.4詳細代碼
4.4.1結構體定義
typedef struct//定義了一個結構體變量 { char stu_name[10]; //表示姓名 int
stu_id; //表示學號 double stu_math; //高數(shù)成績 double
stu_english; //大學英語成績 } student;
4.4.2主函數(shù)
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h>
4.4.3初始化函數(shù)
student all_stu[10]; int stu_number=0;//定義了學生的人數(shù) int main()
4.4.4顯示菜單函數(shù)
void first();//一號條件 void secend();//二號條件 void third();//三號條件
void fourth();//四號條件 void fifth(); int q; do printf("\n\n\n\n
printf("\t\t=學生成績管理系統(tǒng)\n");
printf("\t\t*
\n"); printf("\t\t 1. 輸入學生成績 \n"); printf("\t\t 2. 查找學生成績 \n"); printf("\t\t 3. 顯示所有成績 \n"); printf("\t\t 4. 刪除學生成績 \n"); printf("\t\t 5. 修改學生成績 \n"); printf("\t\t 0. 退出管理系統(tǒng) \n"); printf("\t\t printf("\t\t=========================================\n);
printf("\t\t輸入你的選項:"); scanf("%d",&q); switch(q) { case 1:
first();
printf(“按任意鍵回菜單”);
getchar();
system(“cls”);//表示轉移號
break; case 2:
secend();
getchar();
printf(“按任意鍵回菜單”);
getchar();
system(“cls”);
break; case 3: third(); getchar(); printf("\n請按任意鍵返回主菜單\n"); getchar(); system(“cls”); break;
case 4: fourth(); getchar(); printf("\n按任意鍵返回主菜單\n");
getchar(); system(“cls”); break; case 5:
fifth();
getchar();
printf("\n按任意鍵回主菜單\n");
getchar();
system(“cls”);
break; } }while(q); return 0;
4.4.5顯示各個功能函數(shù)
4.4.5.1增加信息
void first()
{
thefirst:
system("cls");
printf("************輸入學生信息**********);
printf("\n\n");
int cw,temp,hh;
char op;
stu_number++;
printf("\n>>>>>>>>請輸入姓名: ");
scanf("%s",all_stu[stu_number].stu_name);
printf("\n>>>>>>>>請輸入學號: ");
scanf("%d",&temp);
all_stu[stu_number].stu_id=temp;
getchar();//接收一個空格
printf("\n>>>>>>請輸入高等數(shù)學成績(小于等于100):");
scanf("%lf",&all_stu[stu_number].stu_math);
if (all_stu[stu_number].stu_math> 100)
{
printf("輸入有誤,請輸入正確的成績信息,請按(Y)重新輸入: ");
getchar();
cw = getchar();
if (cw =='y'|| cw =='Y')
goto thefirst;
}
printf("\n>>>>>>>>請輸入大學英語成績(小于等于100):");
scanf("%lf", &all_stu[stu_number].stu_english);
if (all_stu[stu_number].stu_english> 100)
{
printf("輸入有誤,請輸入正確的成績信息,請按(Y)重新輸入: ");
getchar();//接收Y
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefirst;
}
thefirstone:
printf("\n是否繼續(xù)輸入,如是請按(Y),否請按(N): ");
getchar();
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefirst;
if (op == 'n' || op == 'N')
goto thefirstend;
else
goto thefirstone;
getchar();
thefirstend:;
getchar();//輸入任意數(shù)結束
}
4.4.5.2查找信息
void fourth()
{
thefourth:
system("cls");
printf("\n\n\n\n********************刪除學生成績**********************");
int num,cw,cx,ai,i=0;
char op;
printf("\n>>>>>>>>請輸入要查找學生的學號: ");
scanf("%d",&num);
for (ai=1;ai<=stu_number;ai++)
{
if (num==all_stu[ai].stu_id)
{
i=1;
break;
}
}
if (i==0)
{
printf("未查找到要刪除的學生信息,是否要重新輸入,如需要重新輸入請按(Y),如不需要請按(N)將返回主菜單: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefourth;//回到開始
if (cw == 'n' || cw == 'N')
goto thefourthend;//回到結尾
}
else
{
stu_number--;//人數(shù)減一
for (;ai<stu_number;ai--)
{
all_stu[ai] = all_stu[ai+1];//后面的數(shù)據(jù)往前推
}
}
printf("\n\n此學號的學生成績信息已刪除");
getchar();
thefourthone:
getchar();
printf("\n刪除的成績信息以刪除,是否繼續(xù)?\n需要請(Y),如不需要請(N),將返回主界面: ");
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefourth;
if (op == 'n' || op == 'N')
goto thefourthend;
else
goto thefourthone;
thefourthend:;
}
4.4.5.3顯示信息
> void third() { thethird: system("cls");
> printf("\n\n**************************顯示學生信息***********************");
> int n=1; printf("\n\n>>>姓名"); printf("\t學號"); printf("\t高等數(shù)學");
> printf("\t大學英語"); //for (n=0;n<stu_number;n++); do {
> printf("\n>>%s", all_stu[n].stu_name); printf("\t%d",
> all_stu[n].stu_id); printf("\t%.2lf", all_stu[n].stu_math);
> printf("\t%.2lf", all_stu[n].stu_english); n++; } while
> (n<=stu_number); }
4.4.5.4刪除信息
void fourth()
{
thefourth:
system("cls");
printf("\n\n\n\n********************刪除學生成績**********************");
int num,cw,cx,ai,i=0;
char op;
printf("\n>>>>>>>>請輸入要查找學生的學號: ");
scanf("%d",&num);
for (ai=1;ai<=stu_number;ai++)
{
if (num==all_stu[ai].stu_id)
{
i=1;
break;
}
}
if (i==0)
{
printf("未查找到要刪除的學生信息,是否要重新輸入,如需要重新輸入請按(Y),如不需要請按(N)將返回主菜單: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefourth;//回到開始
if (cw == 'n' || cw == 'N')
goto thefourthend;//回到結尾
}
else
{
stu_number--;//人數(shù)減一
for (;ai<stu_number;ai--)
{
all_stu[ai] = all_stu[ai+1];//后面的數(shù)據(jù)往前推
}
}
printf("\n\n此學號的學生成績信息已刪除");
getchar();
thefourthone:
getchar();
printf("\n刪除的成績信息以刪除,是否繼續(xù)?\n需要請(Y),如不需要請(N),將返回主界面: ");
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefourth;
if (op == 'n' || op == 'N')
goto thefourthend;
else
goto thefourthone;
thefourthend:;
}
4.4.5.5修改信息
void fifth()//修改成績
{
thefifth:
system("cls");
printf("**************************修改學生成績*************************");
printf("\n\n");
int num,cw,cx,ai,i = 0, cy, temp;
char op;
printf("\n>>>>>>>>請輸入要查找學生的學號: ");
scanf("%d", &num);
for (ai=1; ai<=stu_number; ai++)
{
if (num ==all_stu[ai].stu_id)
{
i = 1;
break;
}
}
if (i == 0)
{
printf("未查找到要修改的學生信息,重新輸入按Y,返回主菜單按N ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifth;
if (cw == 'n' || cw == 'N')
goto thefifthend;
}
else
{
printf("***********************************************************************");
printf("\n*姓名___: ");
printf("%s", all_stu[ai].stu_name);
printf("\n*學號___: ");
printf("%d", all_stu[ai].stu_id);
printf("\n*高數(shù)成績: ");
printf("%.2lf", all_stu[ai].stu_math);
printf("\n*大學英語成績: ");
printf("%.2lf",all_stu[ai].stu_english);
printf("\n*********************************************************************");
}
getchar();
printf("\n\n是否確認修改此學生成績信息?(注:修改后將不可還原)如需修改請按Y,如不需修改學生信息請安N返回主菜單: ");
thefifthone:
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
if (cw == 'n' || cw == 'N')
goto thefifthend;
else
goto thefifthone;
thefifthtwo:
system("cls");
printf("\n>>>>>>>>請輸入姓名: ");
scanf("%s", all_stu[ai].stu_name);
printf("\n>>>>>>>>請輸入學號: ");
scanf("%d",&temp);
all_stu[ai].stu_id = temp;
getchar();
for (cy = 0; cy < ai; cy++)
{
if (all_stu[ai].stu_id == all_stu[cy].stu_id)
{
printf("學號輸入錯誤,如需重新輸入請按(Y)退出請按(N)");
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
else
goto thefifthend;
}
}
printf("\n>>>>>>>>請輸入第一門成績(小于100): ");
scanf("%lf", &all_stu[ai].stu_math);
if (all_stu[ai].stu_math > 100)
{
printf("輸入有誤,請按(Y)重新輸入: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
}
printf("\n>>>>>>>>請輸入第二門成績(小于100): ");
scanf("%lf", &all_stu[ai].stu_english);
if (all_stu[ai].stu_english > 100)
{
printf("輸入有誤,請按(Y)重新輸入: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
}
printf("\n\n");
printf("\n OK 此學生成績信息已修改完成,感謝您的使用。");
thefifthfanhui:
getchar();
printf("\n成績信息已修改,是否繼續(xù)?\n需要請按Y,如不需要請按Y,將返回主菜單: ");
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefifth;
if (op == 'n' || op == 'N')
goto thefifthend;
else
goto thefifthfanhui;
thefifthend:;
}
4.5使用說明
本代碼比較簡單易懂,蒟蒻也能看懂。
4.6測試結果與分析
主界面如圖:

輸入信息圖示:

查找信息如圖:

顯示所有信息如圖:

刪除學生信息:

修改學生信息如圖:


4.7參考文獻
【1】c語言從入門到精通2020版。
5體會與感想
學習的過程很漫長,只有依靠自己的慢慢摸索,在過程中總結出經驗才是學習中最重要的事情。
6附錄
附錄
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int sum;
typedef struct//定義了一個結構體變量
{
char stu_name[10]; //表示姓名
int stu_id; //表示學號
double stu_math; //高數(shù)成績
double stu_english; //大學英語成績
} student;
student all_stu[10];
int stu_number=0;//定義了學生的人數(shù)
int main()
{
void first();//一號條件
void secend();//二號條件
void third();//三號條件
void fourth();//四號條件
void fifth();
int q;
do
{
printf("\n\n\n\n");
printf("\t\t=====================學生成績管理系統(tǒng)=================\n");
printf("\t\t* *\n");
printf("\t\t* 1. 輸入學生成績 *\n");
printf("\t\t* 2. 查找學生成績 *\n");
printf("\t\t* 3. 顯示所有成績 *\n");
printf("\t\t* 4. 刪除學生成績 *\n");
printf("\t\t* 5. 修改學生成績 *\n");
printf("\t\t* 0. 退出管理系統(tǒng) *\n");
printf("\t\t* 歡迎使用! *\n");
printf("\t\t=======================================================\n");
printf("\t\t輸入你的選項:");
scanf("%d",&q);
switch(q)
{
case 1:
first();
printf("按任意鍵回菜單");
getchar();
system("cls");//表示轉移號
break;
case 2:
secend();
getchar();
printf("按任意鍵回菜單");
getchar();
system("cls");
break;
case 3:
third();
getchar();
printf("\n請按任意鍵返回主菜單\n");
getchar();
system("cls");
break;
case 4:
fourth();
getchar();
printf("\n按任意鍵返回主菜單\n");
getchar();
system("cls");
break;
case 5:
fifth();
getchar();
printf("\n按任意鍵回主菜單\n");
getchar();
system("cls");
break;
}
}while(q);
return 0;
}
void first()
{
thefirst:
system("cls");
printf("********************************輸入學生信息*********************************");
printf("\n\n");
int cw,temp,hh;
char op;
stu_number++;
printf("\n>>>>>>>>請輸入姓名: ");
scanf("%s",all_stu[stu_number].stu_name);
printf("\n>>>>>>>>請輸入學號: ");
scanf("%d",&temp);
all_stu[stu_number].stu_id=temp;
getchar();//接收一個空格
printf("\n>>>>>>>>請輸入高等數(shù)學成績(小于等于100):");
scanf("%lf",&all_stu[stu_number].stu_math);
if (all_stu[stu_number].stu_math> 100)
{
printf("輸入有誤,請輸入正確的成績信息,請按(Y)重新輸入: ");
getchar();
cw = getchar();
if (cw =='y'|| cw =='Y')
goto thefirst;
}
printf("\n>>>>>>>>請輸入大學英語成績(小于等于100):");
scanf("%lf", &all_stu[stu_number].stu_english);
if (all_stu[stu_number].stu_english> 100)
{
printf("輸入有誤,請輸入正確的成績信息,請按(Y)重新輸入: ");
getchar();//接收Y
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefirst;
}
thefirstone:
printf("\n是否繼續(xù)輸入,如是請按(Y),否請按(N): ");
getchar();
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefirst;
if (op == 'n' || op == 'N')
goto thefirstend;
else
goto thefirstone;
getchar();
thefirstend:;
getchar();//輸入任意數(shù)結束
}
void secend()
{
thesecend:
system("cls");
printf("\n\n**************************查找學生成績*************************");
int data,cw,j,flag=0;
char op;
printf("\n>>>>>>>>請輸入要查找學生的學號:");
scanf("%d",&data);
for (j=1;j<=stu_number;j++)
{
if(data==all_stu[j].stu_id)
{
flag=1;
break;
}
}
if (flag==0)
{
printf("未查找到此學號,重新輸入請按(Y),如不需要請按(N)將返回主菜單: ");
getchar();
cw=getchar();
if (cw=='y'||cw=='Y')
goto thesecend;
if (cw == 'n' || cw == 'N')
goto thesecendend;
}
else
{
for(j=1;j<=stu_number;j++){
printf("\n***********************************************");
printf("\n*姓名___: ");
printf("%s",all_stu[j].stu_name);
printf("\n*學號___: ");
printf("%d",all_stu[j].stu_id);
printf("\n*高數(shù)_: ");
printf("%.2lf", all_stu[j].stu_math);
printf("\n*大學英語_: ");
printf("%.2lf", all_stu[j].stu_english);
printf("\n************************************************");
}
}
thesecendone:
getchar();
printf("\n輸入錯誤,是否繼續(xù)查閱?\n需要按(Y),如不需要按(N),將返回主界面:");
scanf("%c",&op);
if (op =='y' || op =='Y')
goto thesecend;
if (op =='n' || op =='N')
goto thesecendend;
else
goto thesecendone;
thesecendend:;
}
void third()
{
thethird:
system("cls");
printf("\n\n*********************顯示學生信息******************************");
int n=1;
printf("\n\n>>>姓名");
printf("\t學號");
printf("\t高等數(shù)學");
printf("\t大學英語");
//for (n=0;n<stu_number;n++);
do
{
printf("\n>>%s", all_stu[n].stu_name);
printf("\t%d", all_stu[n].stu_id);
printf("\t%.2lf", all_stu[n].stu_math);
printf("\t%.2lf", all_stu[n].stu_english);
n++;
} while (n<=stu_number);
}
void fourth()
{
thefourth:
system("cls");
printf("\n\n\n\n********************刪除學生成績**********************");
int num,cw,cx,ai,i=0;
char op;
printf("\n>>>>>>>>請輸入要查找學生的學號: ");
scanf("%d",&num);
for (ai=1;ai<=stu_number;ai++)
{
if (num==all_stu[ai].stu_id)
{
i=1;
break;
}
}
if (i==0)
{
printf("未查找到要刪除的學生信息,是否要重新輸入,如需要重新輸入請按(Y),如不需要請按(N)將返回主菜單: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefourth;//回到開始
if (cw == 'n' || cw == 'N')
goto thefourthend;//回到結尾
}
else
{
stu_number--;//人數(shù)減一
for (;ai<stu_number;ai--)
{
all_stu[ai] = all_stu[ai+1];//后面的數(shù)據(jù)往前推
}
}
printf("\n\n此學號的學生成績信息已刪除");
getchar();
thefourthone:
getchar();
printf("\n刪除的成績信息以刪除,是否繼續(xù)?\n需要請(Y),如不需要請(N),將返回主界面: ");
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefourth;
if (op == 'n' || op == 'N')
goto thefourthend;
else
goto thefourthone;
thefourthend:;
}
void fifth()//修改成績
{
thefifth:
system("cls");
printf("**************************修改學生成績*************************");
printf("\n\n");
int num,cw,cx,ai,i = 0, cy, temp;
char op;
printf("\n>>>>>>>>請輸入要查找學生的學號: ");
scanf("%d", &num);
for (ai=1; ai<=stu_number; ai++)
{
if (num ==all_stu[ai].stu_id)
{
i = 1;
break;
}
}
if (i == 0)
{
printf("未查找到要修改的學生信息,重新輸入按Y,返回主菜單按N ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifth;
if (cw == 'n' || cw == 'N')
goto thefifthend;
}
else
{
printf("***************************************************************************");
printf("\n*姓名___: ");
printf("%s", all_stu[ai].stu_name);
printf("\n*學號___: ");
printf("%d", all_stu[ai].stu_id);
printf("\n*高數(shù)成績: ");
printf("%.2lf", all_stu[ai].stu_math);
printf("\n*大學英語成績: ");
printf("%.2lf",all_stu[ai].stu_english);
printf("\n***************************************************************************");
}
getchar();
printf("\n\n是否確認修改此學生成績信息?(注:修改后將不可還原)如需修改請按Y,如不需修改學生信息請安N返回主菜單: ");
thefifthone:
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
if (cw == 'n' || cw == 'N')
goto thefifthend;
else
goto thefifthone;
thefifthtwo:
system("cls");
printf("\n>>>>>>>>請輸入姓名: ");
scanf("%s", all_stu[ai].stu_name);
printf("\n>>>>>>>>請輸入學號: ");
scanf("%d",&temp);
all_stu[ai].stu_id = temp;
getchar();
for (cy = 0; cy < ai; cy++)
{
if (all_stu[ai].stu_id == all_stu[cy].stu_id)
{
printf("學號輸入錯誤,如需重新輸入請按(Y)退出請按(N)");
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
else
goto thefifthend;
}
}
printf("\n>>>>>>>>請輸入第一門成績(小于100): ");
scanf("%lf", &all_stu[ai].stu_math);
if (all_stu[ai].stu_math > 100)
{
printf("輸入有誤,請按(Y)重新輸入: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
}
printf("\n>>>>>>>>請輸入第二門成績(小于100): ");
scanf("%lf", &all_stu[ai].stu_english);
if (all_stu[ai].stu_english > 100)
{
printf("輸入有誤,請按(Y)重新輸入: ");
getchar();
cw = getchar();
if (cw == 'y' || cw == 'Y')
goto thefifthtwo;
}
printf("\n\n");
printf("\n OK 此學生成績信息已修改完成,感謝您的使用。");
thefifthfanhui:
getchar();
printf("\n成績信息已修改,是否繼續(xù)?\n需要請按Y,如不需要請按Y,將返回主菜單: ");
scanf("%c", &op);
if (op == 'y' || op == 'Y')
goto thefifth;
if (op == 'n' || op == 'N')
goto thefifthend;
else
goto thefifthfanhui;
thefifthend:;
}
by:一個剛剛學習c語言的大學生~~
到此這篇關于C語言不用鏈表完成學生管理系統(tǒng)(完整代碼)的文章就介紹到這了,更多相關c語言學生管理系統(tǒng)內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
C語言實現(xiàn)可保存的動態(tài)通訊錄的示例代碼
這篇文章主要為大家詳細介紹了如何利用C語言實現(xiàn)一個簡單的可保存的動態(tài)通訊錄,文中的示例代碼講解詳細,對我們學習C語言有一定幫助,需要的可以參考一下2022-07-07
深入探討Linux靜態(tài)庫與動態(tài)庫的詳解(一看就懂)
本篇文章是對Linux靜態(tài)庫與動態(tài)庫進行了詳細的分析介紹,需要的朋友參考下2013-05-05

