當前位置:首頁 » 考試成績 » 學生成績管理系統代碼整合

學生成績管理系統代碼整合

發布時間: 2021-01-08 19:15:34

學生成績管理系統代碼200行

這可能是不行的哦

❷ 學生成績管理系統的源代碼

#include "stdio.h"

/*定義學生結構體*/

struct Student

{

char ID[20];

char Name[20];

float Mark1;

float Mark2;

float Mark3;

float Average;

};

/*聲明學生數組及學生數量*/

struct Student students[1000];

int num=0;

/*求平均值*/

float Avg(struct Student stu)

{

return (stu.Mark1+stu.Mark2+stu.Mark3)/3;

}

/*通過學號返回數組下標*/

int Student_SearchByIndex(char id[])

{

int i;

for (i=0;i<num;i++)

{

if (strcmp(students[i].ID,id)==0)

{

return i;

}

}

return -1;

}

/*通過姓名返回數組下標*/

int Student_SearchByName(char name[])

{

int i;

for (i=0;i<num;i++)

{

if (strcmp(students[i].Name,name)==0)

{

return i;

}

}

return -1;

}

/*顯示單條學生記錄*/

void Student_DisplaySingle(int index)

{

printf("%10s%10s%8s%8s%8s%10s\n","學號","姓名","成績","成績","成績","平均成績");

printf("-------------------------------------------------------------\n");

printf("%10s%10s%8.2f%8.2f%8.2f%10.2f\n",students[index].ID,students[index].Name,

students[index].Mark1,students[index].Mark2,students[index].Mark3,students[index].Average);

}

/*插入學生信息*/

void Student_Insert()

{

while(1)

{

printf("請輸入學號:");

scanf("%s",&students[num].ID);

getchar();

printf("請輸入姓名:");

scanf("%s",&students[num].Name);

getchar();

printf("請輸入成績:");

scanf("%f",&students[num].Mark1);

getchar();

printf("請輸入成績:");

scanf("%f",&students[num].Mark2);

getchar();

printf("請輸入成績:");

scanf("%f",&students[num].Mark3);

getchar();

students[num].Average=Avg(students[num]);

num++;

printf("是否繼續?(y/n)");

if (getchar()=='n')

{

break;

}

}

}

/*修改學生信息*/

void Student_Modify()

{

float mark1,mark2,mark3;

while(1)

{

char id[20];

int index;

printf("請輸入要修改的學生的學號:");

scanf("%s",&id);

getchar();

index=Student_SearchByIndex(id);

if (index==-1)

{

printf("學生不存在!\n");

}

else

{

printf("你要修改的學生信息為:\n");

Student_DisplaySingle(index);

printf("-- 請輸入新值--\n");

printf("請輸入學號:");

scanf("%s",&students[index].ID);

getchar();

printf("請輸入姓名:");

scanf("%s",&students[index].Name);

getchar();

printf("請輸入成績:");

scanf("%f",&students[index].Mark1);

getchar();

printf("請輸入成績:");

scanf("%f",&students[index].Mark2);

getchar();

printf("請輸入成績:");

scanf("%f",&students[index].Mark3);

getchar();

students[index].Average=Avg(students[index]);

}

printf("是否繼續?(y/n)");

if (getchar()=='n')

{

break;

}

}

}

/*刪除學生信息*/

void Student_Delete()

{

int i;

while(1)

{

char id[20];

int index;

printf("請輸入要刪除的學生的學號:");

scanf("%s",&id);

getchar();

index=Student_SearchByIndex(id);

if (index==-1)

{

printf("學生不存在!\n");

}

else

{

printf("你要刪除的學生信息為:\n");

Student_DisplaySingle(index);

printf("是否真的要刪除?(y/n)");

if (getchar()=='y')

{

for (i=index;i<num-1;i++)

{

students[i]=students[i+1];

}

num--;

}

getchar();

}

printf("是否繼續?(y/n)");

if (getchar()=='n')

{

break;

}

}

}

/*按姓名查詢*/

void Student_Select()

{

while(1)

{

char name[20];

int index;

printf("請輸入要查詢的學生的姓名:");

scanf("%s",&name);

getchar();

index=Student_SearchByName(name);

if (index==-1)

{

printf("學生不存在!\n");

}

else

{

printf("你要查詢的學生信息為:\n");

Student_DisplaySingle(index);

}

printf("是否繼續?(y/n)");

if (getchar()=='n')

{

break;

}

}

}

/*按平均值排序*/

void Student_SortByAverage()

{

int i,j;

struct Student tmp;

for (i=0;i<num;i++)

{

for (j=1;j<num-i;j++)

{

if (students[j-1].Average<students[j].Average)

{

tmp=students[j-1];

students[j-1]=students[j];

students[j]=tmp;

}

}

}

}

/*顯示學生信息*/

void Student_Display()

{

int i;

printf("%10s%10s%8s%8s%8s%10s\n","學號","姓名","成績","成績","成績","平均成績");

printf("-------------------------------------------------------------\n");

for (i=0;i<num;i++)

{

printf("%10s%10s%8.2f%8.2f%8.2f%10.2f\n",students[i].ID,students[i].Name,

students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Average);

}

}

/*將學生信息從文件讀出*/

void IO_ReadInfo()

{

FILE *fp;

int i;

if ((fp=fopen("Database.txt","rb"))==NULL)

{

printf("不能打開文件!\n");

return;

}

if (fread(&num,sizeof(int),1,fp)!=1)

{

num=-1;

}

else

{

for(i=0;i<num;i++)

{

fread(&students[i],sizeof(struct Student),1,fp);

}

}

fclose(fp);

}

/*將學生信息寫入文件*/

void IO_WriteInfo()

{

FILE *fp;

int i;

if ((fp=fopen("Database.txt","wb"))==NULL)

{

printf("不能打開文件!\n");

return;

}

if (fwrite(&num,sizeof(int),1,fp)!=1)

{

printf("寫入文件錯誤!\n");

}

for (i=0;i<num;i++)

{

if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1)

{

printf("寫入文件錯誤!\n");

}

}

fclose(fp);

}

/*主程序*/

main()

{

int choice;

IO_ReadInfo();

while(1)

{

/*主菜單*/

printf("\n------ 學生成績管理系統------\n");

printf("1. 增加學生記錄\n");

printf("2. 修改學生記錄\n");

printf("3. 刪除學生記錄\n");

printf("4. 按姓名查詢學生記錄\n");

printf("5. 按平均成績排序\n");

printf("6. 退出\n");

printf("請選擇(1-6):");

scanf("%d",&choice);

getchar();

switch(choice)

{

case 1:

Student_Insert();

break;

case 2:

Student_Modify();

break;

case 3:

Student_Delete();

break;

case 4:

Student_Select();

break;

case 5:

Student_SortByAverage();

Student_Display();

break;

case 6:

exit();

break;

}

IO_WriteInfo();

}

}

❸ 學生成績管理系統的代碼

實現了樓主要求功能,樓主可以參考一下,另外希望樓主採納哦,嘿嘿嘿~~~
唉,白寫這么多代碼了,你都不看的,以後不來網路嘍~~~
#include<iostream.h>
#include<stdio.h>
#include<iomanip.h>
#include<string.h>
#include<stdlib.h>
struct student
{
int number; //學號
char name[10]; //學生姓名
int common; //平時成績
int mid; //期中成績
int end; //期末成績
int sum; //總成績
}stud[50];
int menu() //菜單選項
{
char c;
cout<<"***************成績管理系統*****************"<<endl;
cout<<"輸入1輸入學生成績數據"<<endl;
cout<<"輸入2顯示學生成績數據"<<endl;
cout<<"輸入3查找學生成績數據"<<endl;
cout<<"輸入4顯示不合格學生數據"<<endl;
cout<<"輸入5排序並且評定獎學金獲得情況"<<endl;
cout<<"輸入0程序運行結束界面"<<endl;
cout<<"請輸入編號"<<endl;
cin>>c;
do
{
cout<<"***************成績管理系統*****************"<<endl;
cout<<"輸入1輸入學生成績數據"<<endl;
cout<<"輸入2顯示學生成績數據"<<endl;
cout<<"輸入3查找學生成績數據"<<endl;
cout<<"輸入4顯示不合格學生數據"<<endl;
cout<<"輸入5排序並且評定獎學金獲得情況"<<endl;
cout<<"輸入0程序運行結束界面"<<endl;
}while(c>'5'||c<'0');
system("cls");
return c-'0';
}
void input(int num) //輸入學生數據
{
int i;
cout<<"請輸入學生數據:"<<endl;
for(i=0;i<num;i++)
{
cout<<"學號 姓名 平時成績 期中成績 期末成績 "<<endl;
cin>>stud[i].number;
cin>>stud[i].name;
cin>>stud[i].common;
cin>>stud[i].mid;
cin>>stud[i].end;
}
}
void display(int num) //顯示輸入的數據
{
int i;
cout<<"輸入的數據為:"<<endl;
for(i=0;i<num;i++)
{
cout<<"學號 姓名 平時成績 期中成績 期末成績 總成績"<<endl;
stud[i].sum=stud[i].common+stud[i].mid+stud[i].end;
cout<<setw(4)<<stud[i].number<<setw(4)<<stud[i].name;
cout<<setw(4)<<stud[i].number<<setw(4)<<stud[i].mid;
cout<<setw(4)<<stud[i].end<<setw(4)<<stud[i].sum<<endl;
}
}
void charge(int num) //補考學生數據
{
int i;
for(i=0;i<num;i++)
{
if(stud[i].mid<60||stud[i].end<60||stud[i].common<60)
cout<<"需要補考學生數據"<<endl;
cout<<"學號:"<<stud[i].number<<"姓名"<<stud[i].sum<<endl;
}
}
void search(int num) //查詢一個學生的數據
{
int i;
int m;
cin>>m;
for(i=0;i<num;i++)
{
if(m==stud[i].number)
cout<<"學號"<<stud[i].number<<"姓名"<<stud[i].name<<endl;
else
cout<<"沒有該生信息"<<endl;
break;
}
}
void order(int num) //排序並且評出獲得獎學金的學生
{
int i,j,temp;
for(i=0;i<num-1;i++)
for(j=1;j<num;j++)
{
if(stud[i].sum<stud[j].sum)
{
temp=stud[i].sum;
stud[i].sum=stud[j].sum;
stud[j].sum=temp;
}
}
cout<<"1-2名為A等獎學金"<<endl;
cout<<"3-5名為B等獎學金"<<endl;
cout<<"6-9名為C等獎學金"<<endl;
for(i=0;i<num;i++)
{
cout<<"學生的名次為:"<<endl;
cout<<"第"<<i+1<<"名為:"<<stud[i].name<<endl;
if(i+1==2||i+1==1)
cout<<"A等獎學金"<<endl;
else
if(i+1<=5&&i+1>=3)
cout<<"B等獎學金"<<endl;
else
if(i+1<=9&&i+1>=6)
cout<<"C等獎學金"<<endl;
else
cout<<"沒有獲得獎學金"<<endl;
}
}
void main()
{
int num,n;
cout<<"請輸入學生的人數:";
cin>>num;
menu();
for(;;)
{
switch(n=menu())
{
case 1:
input(num);
break;
case 2:
display(num);
break;
case 3:
search(num);
break;
case 4:
charge(num);
break;
case 5:
order(num);
break;
default:
cout<<"歡迎使用O(∩_∩)O"<<endl;
break;
}
}
system("pause");
}

❹ 學生信息管理系統最簡單源代碼。

方法一:

1、創建抄一個c語言項目。然後右鍵頭文件,創建一個Stu的頭文件。

❺ 求用Java編寫的學生成績管理系統的完整代碼,要能運行的

以下方法實現了用戶界面登陸
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用戶名:");//使用文本創建一個用戶名標簽
TextField t1=new TextField();//創建一個文本框對象
Label password=new Label("密碼:");//創建一個密碼標簽
TextField t2=new TextField();
Button b1=new Button("登陸");//創建登陸按鈕
Button b2=new Button("取消");//創建取消按鈕
public DengLuJieMian()
{
this.setTitle("學生信息管理系統");//設置窗口標題
this.setLayout(null);//設置窗口布局管理器
username.setBounds(50,40,60,20);//設置姓名標簽的初始位置
this.add(username);// 將姓名標簽組件添加到容器
t1.setBounds(120,40,80,20);// 設置文本框的初始位置
this.add(t1);// 將文本框組件添加到容器
password.setBounds(50,100,60,20);//密碼標簽的初始位置
this.add(password);//將密碼標簽組件添加到容器
t2.setBounds(120,100,80,20);//設置密碼標簽的初始位置
this.add(t2);//將密碼標簽組件添加到容器
b1.setBounds(50,150,60,20);//設置登陸按鈕的初始位置
this.add(b1);//將登陸按鈕組件添加到容器
b2.setBounds(120,150,60,20);//設置取消按鈕的初始位置
this.add(b2);// 將取消按鈕組件添加到容器
b1.addActionListener(this);//給登陸按鈕添加監聽器
b2.addActionListener(this);// 給取消按鈕添加監聽器

this.setVisible(true);//設置窗口的可見性
this.setSize(300,200);//設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});//通過內部類重寫關閉窗體的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//處理登陸事件
{
String name=t1.getText();
String pass=t2.getText();
if(name!=null&&pass.equals("000123"))//判斷語句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函數
{
new DengLuJieMian();
}
}
以下方法實現了學生界面設計
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//創建菜單欄
Menu m1=new Menu("信息");//創建菜單「信息」
MenuItem m11=new MenuItem("插入");//創建「插入」的菜單項
MenuItem m12=new MenuItem("查詢");
Menu m2=new Menu("成績");//創建菜單「成績」
MenuItem m21=new MenuItem("查詢");
public StudentJieMian()
{
this.setTitle("學生界面");//設置窗口標題
this.setLayout(new CardLayout());//設置窗口布局管理器
this.setMenuBar(m);//將菜單欄組件添加到容器
m.add(m1);//將信息菜單放入菜單欄
m.add(m2);
m1.add(m11);//將「插入」菜單項添加到「信息」菜單
m1.add(m12); //將「查詢」菜單項添加到「信息」菜單
m2.add(m21); //將「查詢」菜單項添加到「成績」菜單
m11.addActionListener(this); //給「插入」菜單項添加監聽器
m12.addActionListener(this); //給「查詢」菜單項添加監聽器
m21.addActionListener(this); //給「查詢」菜單項添加監聽器
this.setVisible(true); //設置窗口的可見性
this.setSize(300,200); //設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//關閉窗口
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //處理「添加信息」事件
{
new AddStudent();
}
if(e.getSource()==m12) //處理「查詢信息」事件
{
new SelectStudent();
}
if(e.getSource()==m21) //處理「查詢成績」事件
{
new ChengJiStudent();
}
}
public static void main(String args[])
{ new StudentJieMian(); //創建一個對象 }

❻ 學生成績管理系統C語言代碼

#include"stdio.h"
#include<string.h>
#include<stdlib.h>

#define N 30
struct student
{
int num;
char name[20];
int age;
int Math;
int English;
int Physical;
long int sum;
}stu[N];

enter()
{int i,n;
printf("How many students(1-%d)?:",N);
scanf("%d",&n);
printf("\nEnter data now\n\n");
for(i=0;i<n;i++)
{printf("\n Input %dth student record.\n",i+1);
input(i);
}
if(i!=0) save(n);
printf_back(); /* browse or back */
}

add()
{int i,n,m,k;
FILE *fp;
n=load();
printf("How many students are you want to add(1-%d)?:",N-n);
scanf("%d",&m);
k=m+n;
for(i=n;i<k;i++)
{printf("\n Input %dth student record.\n",i+1);
input(i);
}
if((fp=fopen("score.txt","ab"))==NULL)
{printf("Cannot open file.\n");
}
for(i=n;i<k;i++)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
printf("file write error.\n");
fclose(fp);
printf_back();
}

/* insert()
{int n,c;
struct student s;
n=load();
puts("\n Input one data.\n");
do
{input(n);
printf_face();
printf_one(n);
printf("\n\nAre you sure?\n\n\t 1.Sure\t2.cancel and again\t3.Back without save [ ]\b\b");
scanf("%d",&c);
if(c==1)
{
save(n+1);
printf_back();
}
else if(c!=2) menu();
}
while(c==2);
} */

modify()
{struct student s;
FILE *fp;
int i,n,k,w0=1,w1,w2=0;
n=load();
do
{
k=-1;
printf_face();
for(i=0;i<n;i++)
{if((i!=0)&&(i%10==0))
{printf("\n\nRemember NO.031073- which needed modify.Pass any key to continue ...");
getch();
puts("\n\n");
}
printf_one(i);
printf("\n");
}
do
{printf("\n\nEnter NO.031073- that you want to modify! NO.:031073-");
scanf("%d",&s.num);
for(i=0;i<n;i++)
if(s.num==stu[i].num)
{k=i;
s=stu[i]; /* chengji beifei */
}
if(k==-1) printf("\n\nNO exist!please again");
}
while(k==-1);
printf_face();
printf_one(k);
w1=modify_data(k,n);
if(w1==1)
{printf("\nSuccessful ^_^.\n\nAre you modify another?\n\n\t1.Yes2.Back with save\t[ ]\b\b");
scanf("%d",&w0);
w2=1;
}
else
{w0=0; /* end */
if(w2==1)
stu[k]=s;
}
if(w0!=1&&w2==1) save(n); /* w0!=1 return w2==1 modify */
}
while(w0==1);
menu();
}

delete()
{struct student s;
FILE *fp;
int i,n,k,w0=1,w1,w2=0;
n=load();
do
{
k=-1;
printf_face();
for(i=0;i<n;i++)
{if((i!=0)&&(i%10==0))
{printf("\n\nRemember NO.031073- which needed delete.Pass any key to continue ...");
getch();
puts("\n\n");
}
printf_one(i);
printf("\n");
}
do
{printf("\n\nEnter NO.031073- that you want to delete! NO.:031073-");
scanf("%d",&s.num);
for(i=0;i<n;i++)
if(s.num==stu[i].num)
{k=i;
s=stu[i]; /* chengji beifei */
}
if(k==-1) printf("\n\nNO exist!please again");
}
while(k==-1);
printf_face();
printf_one(k);
printf("\nAre you sure?\n\n\t1.Sure2.Back without save in this time [ ]\b\b");
scanf("%d",&w1);
if(w1==1)
{
stu[k].sum=0;
printf("\nSuccessful ^_^.\n\nAre you delete another?\n\n\t1.Yes2.Back with save\t[ ]\b\b");
scanf("%d",&w0);
w2=1;
}
else
{w0=0; /* end */
if(w2==1)
stu[k]=s;
}
if(w0!=1&&w2==1) save(n);
}
while(w0==1);
menu();
}

modify_score()
{struct student s;
FILE *fp;
int i,n,k,w0=1,w1,w2=0;
n=load();
do
{
k=-1;
printf_face();
for(i=0;i<n;i++)
{if((i!=0)&&(i%10==0))
{printf("\n\nRemember NO.031073 which score needed modify.Pass any key to continue ...");
getch();
puts("\n\n");
}
printf_one(i);
printf("\n");
}
do
{printf("\n\nEnter NO.031073- that you want to modify! NO.:031073-");
scanf("%d",&s.num);
for(i=0;i<n;i++)
if(s.num==stu[i].num)

{k=i;
s=stu[i]; /* chengji beifei */
}
if(k==-1) printf("\n\nNO exist!please again");
}
while(k==-1);
printf_face();
printf_one(k);
w1=modify_score1(k);
if(w1==1)
{printf("\nSuccessful ^_^.\n\nAre you modify another score?\n\n\t1.Yes2.Back with save\t[ ]\b\b");
scanf("%d",&w0);
w2=1;
}
else
{w0=0; /* end */
if(w2==1)
stu[k]=s;
}
if(w0!=1&&w2==1) save(n); /* w0!=1 return w2==1 modify */
}
while(w0==1);
menu();
}

order()
{int i,j,k,n;
struct student s;
n=load();
for(i=0;i<n-1;i++)
{k=i;
for(j=i+1;j<n;j++)
if(stu[j].num<stu[k].num) k=j;
s=stu[i];stu[i]=stu[k];stu[k]=s;
}
save(n);
puts("\n\n");
printf_back();
}

browse()
{int i,j,n;
n=load();
printf_face();
for(i=0;i<n;i++)
{if((i!=0)&&(i%10==0))
{printf("\n\nPass any key to contiune ...");
getch();
puts("\n\n");
}
printf_one(i);
printf("\n");
}
printf("\tThere are %d record.\n",n);
printf("\nPass any key to back...");
getch();
menu();
}

save(int n)
{FILE *fp;
int i;
if((fp=fopen("score.txt","wb"))==NULL)
{printf("\nCannot open file\n");
return NULL;
}
for(i=0;i<n;i++)
if(stu[i].sum!=0)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}

load()
{FILE *fp;
int i;
if((fp=fopen("score.txt","rb"))==NULL)
{printf("\nCannot open file\n");
return NULL;
}
for(i=0;!feof(fp);i++)
fread(&stu[i],sizeof(struct student),1,fp);
fclose(fp);
return(i-1);
}

no_input(int i,int n)
{int k,w1;
do
{w1=0;
printf("NO.:031073-");
scanf("%d",&stu[i].num);
if(stu[i].num<1 || stu[i].num>N)
{puts("Input error! Only be made up of(1-N).Please reinput!\n");
w1=1;
}
if(w1!=1)
for(k=0;k<n;k++)
if(k!=i&&(stu[k].num==stu[i].num))
{puts("This record is exist. Please reinput!\n");
w1=1;break;
}
}
while(w1==1);
}

enter_score(int i)
{printf("Math English Physical");
scanf("%d %d %d",&stu[i].Math,&stu[i].English,&stu[i].Physical);
}
sum(int i)
{
stu[i].sum=stu[i].Math+stu[i].English+stu[i].Physical;
}

input(int i)
{no_input(i,i);
printf("name: age:");
scanf("%s %d",stu[i].name,&stu[i].age);
enter_score(i);
sum(i);
}

modify_score1(int i)
{int c,w1;
do
{
puts("\nmodify by=>\n\n 1.Math 2.English 3.Physical4.all score 5.cancel and back");
printf("Which you needed?:[ ]\b\b");
scanf("%d",&c);
if(c>5||c<1)
{puts("\nChoice error! Please again!");
getchar();
}
}
while(c>5||c<1);
do
{switch(c)
{
case 1:printf("Math:");scanf("%d",&stu[i].Math);break;
case 2:printf("English:");scanf("%d",&stu[i].English);break;
case 3:printf("Physical:");scanf("%d",&stu[i].Physical);break;
case 4:enter_score(i);break;
case 5:break;
}
if(c>0&&c<5) sum(i);
puts("\nNow:\n");
printf_face();
printf_one(i);
printf("\nAre you sure?\n\n\t1.Sure 2.No and remodify3.Back without save in this time [ ]\b\b");
scanf("%d",&w1);
}
while(w1==2);
return(w1);
}

modify_data(int i,int n)
{int c,w1;
do
{
puts("\nmodify by=>\n\n 1.NO. 2.name 3.age 4.Math 5.English 6.Physical7.all score 8.all data 9.cancel and back");
printf("Which you needed?:[ ]\b\b");
scanf("%d",&c);
if(c>9||c<1)
{puts("\nChoice error! Please again!");
getchar();
}
}
while(c>9||c<1);
do
{switch(c)
{case 1:no_input(i,n);break;
case 2:printf("name:");scanf("%s",stu[i].name);break;
case 3:printf("age:");scanf("%d",&stu[i].age);break;
case 4:printf("Math:");scanf("%d",&stu[i].Math);break;
case 5:printf("English:");scanf("%d",&stu[i].English);break;
case 6:printf("Physical:");scanf("%d",&stu[i].Physical);break;
case 7:enter_score(i);break;
case 8:input(i);break;
case 9:break;
}
if(c>3&&c<8) sum(i);
puts("\nNow:\n");
printf_face();
printf_one(i);
printf("\nAre you sure?\n\n\t1.Sure 2.No and remodify3.Back without save in this time [ ]\b\b");
scanf("%d",&w1);
}
while(w1==2);
return(w1);
}

printf_face()
{printf("\nNO.031073 name age Math English Physical sum\n");
}

printf_one(int i)
{
printf("%6d %8s %4d",stu[i].num,stu[i].name,stu[i].age);
printf("%5d %5d %8d %10d",stu[i].Math,stu[i].English,stu[i].Physical,stu[i].sum);
}

printf_back()
{int k,w;
printf("\n\n\tSuccessful.^_^\n\n");
printf("What do you want to do?\n\n\t1.Browse all now\t2.Back:[ ]\b\b");
scanf("%d",&w);
if(w==1) browse();
else menu();
}
menu()
{int w1;
char n;
do
{
puts("\t\t****************MENU****************\n\n");
puts("\t\t\t\tA.Enter new data");
puts("\t\t\t\tB.Addition data");
puts("\t\t\t\tC.Modify data");
puts("\t\t\t\tD.Delete data");
puts("\t\t\t\tE.Modify score");
puts("\t\t\t\tF.Order by number");
puts("\t\t\t\tG.Browse all");
puts("\t\t\t\tH.Exit");
puts("\n\n\t\t************************************\n");
printf("Choice your number(A-H):[ ]\b\b");
n=getchar();
printf("\n");
if(n<'A'||n>'H')
w1=1;
else w1=0;
}
while(w1==1);
switch(n)
{case 'A':enter();break;
case 'B':add();break;
case 'C':modify();break;
case 'D':delete();break;
case 'E':modify_score();break;
case 'F':order();break;
case 'G':browse();break;
case 'H':exit(0);
}
}
char password[7]="123456";
main()
{
char s[7];
printf("\t\t請輸入密碼:\n\t\t\n\t\t");
scanf("%s",s);
if(!strcmp(s,password))
{
printf("\n\t\t恭喜你進入學生成績管理系統\n");
menu();
}
else
{
printf("\t\t 密碼錯誤\n\n");
main();
}
}

❼ 求用Java編寫的學生成績管理系統的完整代碼

packagejdbcproj;
importjava.sql.*;
importjava.awt.BorderLayout;
importjava.awt.EventQueue;

importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.border.EmptyBorder;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JTextField;
importjavax.swing.JButton;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.PreparedStatement;
importjava.sql.SQLException;
importjava.awt.event.ActionEvent;

{

privateJPanelcontentPane;
privateJTextFieldtxtname;
privateJTextFieldtxtpassword;


/**
*Launchtheapplication.
*/
publicstaticvoidmain(String[]args){
.invokeLater(newRunnable(){
publicvoidrun(){
try{
MainFrameframe=newMainFrame();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
}
});
}

/**
*Createtheframe.
*/
publicMainFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,661,399);
contentPane=newJPanel();
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabellblNewLabel=newJLabel("u7528u6237u540D");
lblNewLabel.setBounds(114,51,72,18);
contentPane.add(lblNewLabel);

JLabellblNewLabel_1=newJLabel("u5BC6u7801");
lblNewLabel_1.setBounds(114,106,72,18);
contentPane.add(lblNewLabel_1);

txtname=newJTextField();
txtname.setBounds(261,48,86,24);
contentPane.add(txtname);
txtname.setColumns(10);

txtpassword=newJTextField();
txtpassword.setBounds(261,103,86,24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);

JButtonbtnadd=newJButton("u589Eu52A0");
btnadd.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名和密碼不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45,205,113,27);
contentPane.add(btnadd);

JButtonbtndelete=newJButton("u5220u9664");
btndelete.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventarg0){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAOusdo=newUserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172,205,113,27);
contentPane.add(btndelete);

JButtonbtnupdate=newJButton("u4FEEu6539");
btnupdate.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名和密碼不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300,205,113,27);
contentPane.add(btnupdate);

JButtonbtnfind=newJButton("u67E5u8BE2");
btnfind.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
UserDAOusdo=newUserDAO();
u=usdo.findUser(txtname.getText(),txtpassword.getText());
if(u!=null){
JOptionPane.showMessageDialog(getContentPane(),"該用戶存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(getContentPane(),"該用戶不存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
}
}
});
btnfind.setBounds(427,205,113,27);
contentPane.add(btnfind);
//記得要寫這個
setVisible(true);
}

}

❽ 學生成績管理系統代碼

#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
class student
{ private:
char name[20]; //姓名
double cpro,english,math,sport,law,hbpro,computer;//課程
int order, number; //名次,學號
public:
student(){}
student(char n[20],int nu,double cc,double eng,double ma,double sp,double l,double hb,double com)
{strcpy(name,n);
number=nu;
cpro=cc; english=eng;math=ma;sport=sp;law=l;hbpro=hb;computer=com;
}
friend void main();
};

void main()
{
cout<<" 歡迎進入**學生成績管理系統**!"<<endl;

cout<<" ******************************************"<<endl;
cout<<" **** 學生成績管理系統 ****"<<endl;
cout<<" ******************************************"<<endl;
cout<<" **************************"<<endl;
cout<<" **0、輸入數據 **"<<endl;
cout<<" **1、增加數據 **"<<endl;
cout<<" **2、修改數據 **"<<endl;
cout<<" **3、按姓名查詢 **"<<endl;
cout<<" **4、按學號查詢 **"<<endl;
cout<<" **5、輸出所有學生的成績 **"<<endl;
cout<<" **6、退出系統 **"<<endl;
cout<<" **************************"<<endl;
cout<<" 選擇0-6數字進行操作"<<endl;

char p;char w;
student *s[50]; //指針對象,最多存50個學生數據
ofstream *file[50]; //負責對文件插入操作
int i=0;
int j=0;
int flag=0;
do //flag判斷輸入是否有效
{
cin>>p;
if((p>='0'&&p<='6'))
flag=1;
else
cout<<" 指令錯誤!請重新輸入:"<<endl;
}while(flag==0);
do{
switch(p) //接收功能選項
{
case '0': //輸入數據
{
char c;
char name[20];int number;double cpro,english,math,sport,law,hbpro,computer;
do{
cout<<" 請輸入姓名:";
cin>>name;
cout<<endl<<" 請輸入學號:";
cin>>number;
cout<<" 請輸入C++成績:";
cin>>cpro;
cout<<endl<<" 請輸入英語成績:";
cin>>english;
cout<<endl<<" 請輸入數學成績:";
cin>>math;
cout<<endl<<" 請輸入體育成績:";
cin>>sport;
cout<<endl<<" 請輸入網路基礎成績:";
cin>>law;
cout<<endl<<" 請輸入C語言成績:";
cin>>hbpro;
cout<<endl<<" 請輸入資料庫成績:";
cin>>computer;
cout<<endl;
file[j]=new ofstream("D:\document",ios::ate);
*file[j]<<" 姓名 "<<name<<" 學號 "<<number<<" C++成績 "<<cpro
<<" 英語成績 "<<english<<" 數學成績 "<<math<<" 體育成績 "
<<sport<<" 網路基礎成績 "<<law<<" C成績 "<<hbpro<<" 資料庫成績 "<<computer<<endl;
j++;
s[i]=new student(name, number,cpro,english,math,sport,law,hbpro,computer);
i++;
cout<<" 數據輸入成功,想繼續輸入嗎(y/n):";
cin>>c;
cout<<endl;
do
{
if(c!='y'&&c!='n')
{
cout<<" 指令錯誤!請重新輸入!"<<endl<<" ";
cin>>c;
}
else
flag=1;
}while(flag==0);
}while(c=='y');
break;
}

case '1': //增加數據
{
char name[20];
int number;double cpro,english,math,sport,law,hbpro,computer;
char c;
do
{
cout<<" 請輸入您要增加的學生的姓名:";
cin>>name;
cout<<endl<<" 請輸入學號:";
cin>>number;
cout<<endl<<" 請輸入C++成績:";
cin>>cpro;
cout<<endl<<" 請輸入英語成績:";
cin>>english;
cout<<endl<<" 請輸入數學成績:";
cin>>math;
cout<<endl<<" 請輸入體育成績:";
cin>>sport;
cout<<endl<<" 請輸入網路基礎成績:";
cin>>law;
cout<<endl<<" 請輸入C語言成績:";
cin>>hbpro;
cout<<endl<<" 請輸入資料庫成績:";
cin>>computer;
cout<<endl;

file[j]=new ofstream("d:\document",ios::ate);
*file[j]<<" 姓名 "<<name<<" 學號 "<<number<<" C++成績 "<<cpro<<" 英語成績 "<<english<<" 數學成績 "<<math<<" 體育成績 "<<sport<<" 網路基礎成績 "<<law<<" C成績 "<<hbpro<<" 資料庫成績 "<<computer<<endl;
j++;
s[i]=new student(name, number, cpro,english,math,sport,law,hbpro,computer);
i++;
cout<<" 數據輸入成功,想繼續數入嗎(y/n):";
cin>>c;
cout<<endl;
if(c!='y'&&c!='n')
{
cout<<" 指令錯誤!請重新輸入!"<<endl<<" ";
cin>>c;
}
}while(c=='y');
break;
}

case '2': //修改數據
{
char name[20];int nu;double cc,eng,ma,sp,l,hb,com;flag=0;
char c;
if(i==0)
{
cout<<" 管理系統中沒有輸入數據!"<<endl;break;
}
do
{
cout<<" 請輸入您要修改的學生的姓名:";
cin>>name;
cout<<endl;
for(int h=0;h<i;h++) //h紀錄要修改學生的位置
{
if(strcmp(name,s[h]->name)==0)
{
flag=1;
cout<<" 請輸入新的學號:";
cin>>nu;
cout<<endl<<" 請輸入C++成績:";
cin>>cc;
cout<<endl<<" 請輸入英語成績:";
cin>>eng;
cout<<endl<<" 請輸入數學成績:";
cin>>ma;
cout<<endl<<" 請輸入體育成績:";
cin>>sp;
cout<<endl<<" 請輸入網路基礎成績:";
cin>>l;
cout<<endl<<" 請輸入C語言成績:";
cin>>hb;
cout<<endl<<" 請輸入資料庫成績:";
cin>>com;
cout<<endl;
s[h]->cpro=cc;
s[h]->english=eng;
s[h]->math=ma;
s[h]->sport=sp;
s[h]->law=l;
s[h]->hbpro=hb;
s[h]->computer=com;
s[h]->number=nu;
cout<<" 數據修改成功!"<<endl;
}
}
if(flag==0)
{
cout<<" 您要修改的學生本來就不存在!請檢查重新輸入!"<<endl;
}
cout<<" 想繼續修改嗎(y/n):";
cin>>c;
cout<<endl;
if(c!='y'&&c!='n')
{
cout<<" 指令錯誤!請重新輸入!"<<endl<<" ";
cin>>c;
}
}while(c=='y');
break;
}

case '3': //按姓名查詢
{
char n[20];int j=0;char c;
if(i==0)
{
cout<<" 管理系統中沒有輸入數據!"<<endl;break;
}
do{
int flag=0;
cout<<" 請輸入你要查詢的學生姓名:";
cin>>n;
cout<<endl;
for(int j=0;j<i;j++)
{
if(strcmp(n,(*s[j]).name)==0)
{
flag=1;
cout<<" 您要查詢的學生是:"<<(*s[j]).name<<endl;
cout<<(*s[j]).name<<"的成績是: "<<" C++: "<<(*s[j]).cpro<<" 英語: "<<(*s[j]).english<<" 數學:"<<(*s[j]).math<<" 體育:"<<(*s[j]).sport<<" 法律:"<<(*s[j]).law<<" C:"<<(*s[j]).hbpro<<" 資料庫 "<<(*s[j]).computer<<endl;
}
}
if(flag==0)
cout<<" 對不起!您要查詢的學生不存在!"<<endl;
cout<<" 您想繼續查詢嗎?(y/n):";
cin>>c;
cout<<endl;
if(c!='y'&&c!='n')
{
cout<<" 指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '4': //按學號查詢
{
int n,j=0;char c;
if(i==0){

cout<<" 管理系統中沒有輸入數據!"<<endl;break;
}
do{
int flag=0;
cout<<" 請輸入你要查詢的學生的學號:";
cin>>n;
cout<<endl;
for(int j=0;j<i;j++)
{
if(s[j]->number==n)
{
flag=1;
cout<<" 您要查詢的學生是:"<<(*s[j]).name<<endl;
cout<<(*s[j]).name<<"的成績是: "<<" C++:"<<(*s[j]).cpro<<" 英語:"<<(*s[j]).english<<" 數學:"<<(*s[j]).math<<" 體育:"<<(*s[j]).sport<<" 法律:"<<(*s[j]).law<<" C:"<<(*s[j]).hbpro<<" 資料庫 "<<(*s[j]).computer<<endl;
}
}
if(flag==0)
cout<<" 對不起!您要查詢的學生不存在!"<<endl;
cout<<" 您想繼續查詢嗎?(y/n):";
cin>>c;
cout<<endl;
if(c!='y'&&c!='n')
{
cout<<" 指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '5': //輸出
{
cout<<" 本系統所有學生數據如下:"<<endl;
if(i==0)
cout<<" 管理系統中沒有輸入數據!"<<endl;
cout<<" 姓名 學號 c++ 英語 數學 體育 網路基礎 C語言 資料庫 "<<endl;
for(int k=0;k<i;k++)
{
cout<<s[k]->name<<setw(7)<<s[k]->number<<setw(6)
<<(*s[k]).cpro<<setw(6)<<(*s[k]).english<<setw(6)
<<(*s[k]).math<<setw(6)<<(*s[k]).sport<<setw(7)
<<(*s[k]).law <<setw(10)<<(*s[k]).hbpro<<setw(10)<<(*s[k]).computer<<setw(10)<<endl;
}
break;
}
case'6'://退出
{exit(0); cout<<"Bye bye!"<<endl;}
}
cout<<" 您想繼續進行其他操作嗎?(y/n):";
int flag=0;
do
{
cin>>w;
cout<<endl;
if(w!='y'&&w!='n')
cout<<" 指令錯誤!請重新輸入!"<<endl;
else
flag=1;
}while(flag==0);
if(w=='y')
cout<<" 請輸入操作代碼:0 輸入數據"<<endl;
cout<<" 1 增加數據"<<endl;
cout<<" 2 修改數據"<<endl;
cout<<" 3 按姓名查詢"<<endl;
cout<<" 4 按學號查找"<<endl;
cout<<" 5 輸出所有學生成績"<<endl;
cout<<" 6 退出系統"<<endl;
cin>>p;
}while(w=='y');
}

❾ 求學生成績管理系統的源代碼

#include<stdio.h>
#include<stdlib.h>
#defineFILENAME"student.dat"
typedefenum{MAN,WOMAN}SEX;
typedefstructtagStudent
{
intnum; //學生的編號
charname[20]; //學生的姓名
SEX sex; //學生的性別
intage; //學生的年齡
charmajor[20]; //學生的專業
structtagStudent*next;//下一個節點的指針
}STUDENT,*PSTUDENT;
STUDENTg_head; //頭節點
//1.顯示菜單
voidShowMenu();
//2.獲取用戶選擇的菜單的編號
intGetMenuChoose();
//3.創建一個節點,它會返回一個新創建的學生信息節點的指針
PSTUDENTCreateStudent();
//4.把學生信息節點加入到鏈表中
intAddStudent(PSTUDENTpstu);
//5.返回指定編號學生節點的上一個節點的指針
PSTUDENTGetPrevAddr(intnum);
//6.顯示所有學生信息
voidShowAll();
//7.顯示信息數量
intShowStudentCount();
//8.修改學生信息,參數為要修改的學生的編號
voidModityStudent(intnum);
//9.獲取用戶的選擇
intQuestion(constchar*pstr);
//10.獲取用戶輸入的學生的編號
intGetInputNum();
//11.刪除編號為num的學生信息
voidDelStudent(intnum);
//12.刪除所有的學生信息
voidDelAll();
//13.把學生信息保存到文件當中
voidSaveToFile();
//14.從文件中讀取學生信息
voidLoadFromFile();
intmain()
{
intrunning=1;
while(running)
{
switch(GetMenuChoose())
{
case0:
running=0;
break;
case1:
// printf("你選擇了菜單1 ");
AddStudent(CreateStudent());
break;
case2:
// printf("你選擇了菜單2 ");
DelStudent(GetInputNum());
break;
case3:
printf("你選擇了菜單3 ");
break;
case4:
// printf("你選擇了菜單4 ");
ModityStudent(GetInputNum());
break;
case5:
// printf("你選擇了菜單5 ");
DelAll();
break;
case6:
// printf("你選擇了菜單6 ");
ShowAll();
break;
case7:
// printf("你選擇了菜單7 ");
ShowStudentCount();
break;
case8:
// printf("你選擇了菜單8 ");
LoadFromFile();
break;
case9:
// printf("你選擇了菜單9 ");
SaveToFile();
break;
}
system("pause");
}

return0;
}
//1.顯示菜單
voidShowMenu()
{
system("cls");
printf("-----------------------------學生管理系統-------------------------------- ");
printf(" 1.添加學生信息2.刪除某個學生信息3.顯示某個學生信息 ");
printf(" 4.修改學生信息5.刪除所有學生信息6.顯示所有學生信息 ");
printf(" 7.顯示信息數量8.讀取文件學生信息9.保存學生信息至文件 ");
printf(" 0.退出系統 ");
printf(" ------------------------------------------------------------------------- ");
}
//2.獲取用戶選擇的菜單的編號
intGetMenuChoose()
{
intnum;//保存用戶選擇的菜單編號
ShowMenu();
printf("請選擇菜單(0~9):");
while(1!=scanf("%d",&num)||num<0||num>9)
{
ShowMenu();
printf("選擇菜單錯誤,請重新選擇(0~9):");
fflush(stdin);//清空輸入緩沖區
}
returnnum;
}
//3.創建一個節點,它會返回一個新創建的學生信息節點的指針
PSTUDENTCreateStudent()
{
intsex;
PSTUDENTpstu=(PSTUDENT)malloc(sizeof(STUDENT));//在堆內存申請空間,存儲學生信息
if(!pstu)
{
printf("申請內存空間失敗! ");
returnNULL;
}
printf("請輸入學生的編號(整型):");
while(1!=scanf("%d",&pstu->num)||GetPrevAddr(pstu->num))
{
printf("學生編號輸入錯誤或已經存在,請重新輸入學生的編號(整型):");
fflush(stdin);
}
printf("請輸入學生的姓名(小於20字元):");
scanf("%20s",pstu->name);//(*pstu).name
printf("請選擇學生的性別(1.男2.女):");
while(1!=scanf("%d",&sex)||sex<1||sex>2)
{
printf("性別選擇錯誤,請重新選擇學生的性別(1.男2.女):");
fflush(stdin);
}
if(1==sex)
pstu->sex=MAN;
else
pstu->sex=WOMAN;
printf("請輸入學生的年齡(10~40):");
while(1!=scanf("%d",&pstu->age)||pstu->age<10||pstu->age>40)
{
printf("年齡輸入錯誤!請重新輸入學生的年齡(10~40):");
fflush(stdin);
}
printf("請輸入學生的專業(小於20字元):");
scanf("%20s",pstu->major);
pstu->next=NULL;
returnpstu;
}
//4.把學生信息節點加入到鏈表中
intAddStudent(PSTUDENTpstu)
{
PSTUDENTps=&g_head;
if(!pstu)
{
return0;
}
//判斷一下該學生信息是不是已經存在
if(GetPrevAddr(pstu->num))
{
printf("編號為%d的學生信息已經存在! ",pstu->num);
free(pstu);//釋放該節點內存空間
return0;
}
//while循環的作用是找到當前鏈表的最後一個節點
while(ps->next)
ps=ps->next;
//把新節點加入到最後那個節點的後面
ps->next=pstu;
pstu->next=NULL;
return1;
}
//5.返回指定編號學生節點的上一個節點的指針
PSTUDENTGetPrevAddr(intnum)
{
PSTUDENTpstu=&g_head;
while(pstu->next)
{
if(pstu->next->num==num)
returnpstu;
pstu=pstu->next;
}
returnNULL;
}
//6.顯示所有學生信息
voidShowAll()
{
PSTUDENTpstu=&g_head;
printf("-------------------------------------------------------------------- ");
printf("編號姓名性別年齡專業 ");
printf("-------------------------------------------------------------------- ");
while(pstu->next)
{
printf("%-8d",pstu->next->num);
printf("%-20s",pstu->next->name);
printf("%-6s",pstu->next->sex==MAN?"男":"女");
printf("%4d",pstu->next->age);
printf("%20s ",pstu->next->major);
pstu=pstu->next;//讓指針指向下一個節點
}
printf("-------------------------------------------------------------------- ");
}
//7.顯示信息數量
intShowStudentCount()
{
intcount=0;
PSTUDENTpstu=&g_head;
while(pstu->next)
{
++count;
pstu=pstu->next;
}
printf(" 當前共有%d位學生信息。 ",count);
returncount;
}
//8.修改學生信息,參數為要修改的學生的編號
voidModityStudent(intnum)
{
PSTUDENTpstu=GetPrevAddr(num);//獲取要修改的學生節點的上一個節點
intchoose;
if(!pstu)
{
printf("沒有編號為%d的學生信息。 ",num);
return;
}
pstu=pstu->next;//將要修改的學員節點的指針改為指向自己的
printf("當前學生的姓名為%s,",pstu->name);
if(Question("確定要修改嗎?"))
{
printf("請輸入學生的姓名(小於20字元):");
scanf("%20s",pstu->name);
}
printf("當前學生的性別為%s,",pstu->sex==MAN?"男":"女");
if(Question("確定要修改嗎?"))
{
printf("請輸入學生的性別(1.男2.女):");
while(1!=scanf("%d",&choose)||choose<1||choose>2)
{
printf("輸入錯誤,請重新輸入學生的性別(1.男2.女):");
fflush(stdin);
}
if(1==choose)
pstu->sex=MAN;
else
pstu->sex=WOMAN;
}
printf("當前學生的年齡為%d,",pstu->age);
if(Question("確定要修改嗎?"))
{
printf("請輸入學生的年齡(10~40):");
while(1!=scanf("%d",&pstu->age)||pstu->age<10||pstu->age>40)
{
printf("年齡輸入錯誤!請重新輸入學生的年齡(10~40):");
fflush(stdin);
}
}
printf("當前學生的專業為%s,",pstu->major);
if(Question("確定要修改嗎?"))
{
printf("請輸入學生的專業(小於20字元):");
scanf("%20s",pstu->major);
}
printf("修改完畢! ");
}
//9.獲取用戶的選擇
intQuestion(constchar*pstr)
{
charanswer;
printf("%s請選擇(yorn):",pstr);
while(1!=scanf("%c",&answer)||(answer!='y'&&answer!='n'))
{
printf("輸入錯誤!%s請重新選擇(yorn):",pstr);
fflush(stdin);//清空輸入緩沖區,C庫函數
}
if('y'==answer)
return1;
else
return0;
}
//10.獲取用戶輸入的學生的編號
intGetInputNum()
{
intnum;
printf("請輸入學生的編號(整型):");
while(1!=scanf("%d",&num))
{
printf("編號輸入錯誤!請重新輸入學生的編號(整型):");
fflush(stdin);
}
returnnum;
}
//11.刪除編號為num的學生信息
voidDelStudent(intnum)
{
PSTUDENTpstu,ptmp;
if(pstu=GetPrevAddr(num))
{
if(!Question("確定要刪除該學生信息嗎?"))
{
return;
}
ptmp=pstu->next;
pstu->next=ptmp->next;
free(ptmp);
printf("刪除了編號為%d的學生信息。 ",num);
}
else
{
printf("沒有找到編號為%d的學生信息。 ",num);
}
}
//12.刪除所有的學生信息
voidDelAll()
{
PSTUDENTpstu=g_head.next,ptmp;
intcount=0;
if(!Question("確定要刪除當前所有的學生信息嗎?"))
{
return;
}
while(pstu)
{
ptmp=pstu;
pstu=pstu->next;
free(ptmp);
++count;
}
printf("共刪除了%d位學生信息。 ",count);
g_head.next=NULL;
}
//13.把學生信息保存到文件當中
voidSaveToFile()
{
FILE*pf=fopen(FILENAME,"wb");
PSTUDENTpstu=&g_head;
inti=0,count=ShowStudentCount();
if(!pf)
{
printf("打開待寫入的文件失敗! ");
return;
}
if(!Question("確定要將當前學生信息保存到文件中嗎?"))
{
fclose(pf);
return;
}
fwrite(&count,1,sizeof(count),pf);//把學生信息的數量先寫入到文件頭
while(pstu->next)
{
fwrite(pstu->next,1,sizeof(STUDENT),pf);//把每位學生信息寫入文件
++i;
pstu=pstu->next;
}
fclose(pf);
if(i==count)
{
printf("成功的寫入了%d條學生信息。 ",count);
}
else
{
printf("應寫入%d條學生信息,實際寫入%d條學生信息。 ",count,i);
}
}
//14.從文件中讀取學生信息
voidLoadFromFile()
{
inti,count=0,repeat=0;
FILE*pf;
PSTUDENTpstu;
printf("提示:從文件中讀取學生信息會詢問是否清空當前學生信息(不清空表示合並所有信息)。 ");
if((pf=fopen(FILENAME,"rb"))==NULL)
{
printf("文件還沒有創建,請手工輸入學生信息並保存吧! ");
return;
}
DelAll();//刪除之前的所有學生信息,然後從文件中讀取
fread(&count,1,sizeofcount,pf);//獲取學生信息的數量
for(i=0;i<count;++i)
{
pstu=(PSTUDENT)malloc(sizeof(STUDENT));
fread(pstu,1,sizeof(STUDENT),pf);
if(!AddStudent(pstu))
{
++repeat;//保持有多少個和當前鏈表中相重復的學生信息
}
}
fclose(pf);
printf("文件讀取完畢!新增學生信息%d條。 ",count-repeat);
}

這個累死我了,我要財富值。。。為了這個不容易啊

❿ 學生成績管理系統的代碼是什麼

代碼如下:

for(i=0;i<66;i++)

printf("*");

printf(" ");

printf("1.Input record ");

printf("2.Caculate totel and average score of every course ");

printf("3.Caculate totel and average score of every student ");

printf("4.Sort in descending order by total score of every student ");

printf("5.Sort in ascending order by total score of every student ");

printf("6.Sort in ascending order by number ");

printf("7.Sort in ascending order by name ");

printf("8.Search by number ");

printf("9.Search by name ");

printf("10.Statistic analysis for every course ");

printf("11.List record ");

printf("12.Write to a file ");

printf("13.Read from a file ");

printf("0.Exit ");

for(i=0;i<66;i++)

printf("*");

printf(" ");

printf("Please enter your choice:");

printf(" ");

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919