當前位置:首頁 » 考試成績 » 用mfc實現學生成績

用mfc實現學生成績

發布時間: 2021-01-03 22:40:03

① 基於MFC的學生學習成績管理系統應用程序的實現

數據存儲可以使用Access資料庫。界面使用MFC

② 基於MFC設計並實現一個簡單的學生成績管理系統

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#define LEN sizeof(struct scorenode)
#define DEBUG
#include <string.h>
struct scorenode
{int number;/*學號*/
char name[10];/*姓名*/
float computer;/*計算機 成績*/
float english;/*英語成績*/
float math;/*數學成績 */
struct scorenode *next;
};
typedef struct scorenode score;
int n,k;/*n,k為全局變數,本程序中的函數均可以使用它*/
/*==============================================================================================*/
score *creat(void)/*函數creat,功能:創建鏈表,此函數帶回一個指向鏈表頭的指針*/
{
score*head;
score *p1,*p2,*p3,*max;
int i,j;
float fen;
char t[10];
n=0;
p1=p2=p3=(score *)malloc(LEN);head=p3; /*開辟一個新單元輸入學生相關資料*/
printf("請輸入學生資料,輸0退出!\n");
repeat1: printf("請輸入學生學號(學號應大於0):");
scanf("%d",&p1->number);
while(p1->number<0)
{getchar();
printf("輸入錯誤,請重新輸入學生學號:");
scanf("%d",&p1->number);}
if(p1->number==0)
goto end;
else
{
p3=head;
if(n>0)
{for(i=0;i<n;i++)
{if(p1->number!=p3->number)
p3=p3->next;
else
{printf("學號重復,請重輸!\n");
goto repeat1;
}
}
}
}
printf("請輸入學生姓名:");
scanf("%s",&p1->name);
printf("請輸入計算機 成績(0~100):");
scanf("%f",&p1->computer);
while(p1->computer<0||p1->computer>100)
{getchar();
printf("輸入錯誤,請重新輸入計算機 成績");
scanf("%f",&p1->computer);}
printf("請輸入英語成績(0~100):");
scanf("%f",&p1->english);
while(p1->english<0||p1->english>100)
{getchar();
printf("輸入錯誤,請重新輸入英語成績");
scanf("%f",&p1->english);}
printf("請輸入數學成績(0~100):");
scanf("%f",&p1->math);
while(p1->math<0||p1->math>100)
{getchar();
printf("輸入錯誤,請重新輸入數學成績");
scanf("%f",&p1->math);}
head=NULL;
while(p1->number!=0)
{
n=n+1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(score *)malloc(LEN);
printf("請輸入學生資料,輸0退出!\n");
repeat2:printf("請輸入學生學號(學號應大於0):");
scanf("%d",&p1->number);
while(p1->number<0)
{getchar();
printf("輸入錯誤,請重新輸入學生學號:");
scanf("%d",&p1->number);}
if(p1->number==0)
goto end;
else
{
p3=head;
if(n>0)
{for(i=0;i<n;i++)
{if(p1->number!=p3->number)
p3=p3->next;
else
{printf("學號重復,請重輸!\n");
goto repeat2;
}
}
}
}
printf("請輸入學生姓名:");
scanf("%s",&p1->name);
printf("請輸入計算機 成績(0~100):");
scanf("%f",&p1->computer);
while(p1->computer<0||p1->computer>100)
{getchar();
printf("輸入錯誤,請重新輸入計算機 成績");
scanf("%f",&p1->computer);}
printf("請輸入英語成績(0~100):");
scanf("%f",&p1->english);
while(p1->english<0||p1->english>100)
{getchar();
printf("輸入錯誤,請重新輸入英語成績");
scanf("%f",&p1->english);}
printf("請輸入數學成績(0~100):");
scanf("%f",&p1->math);
while(p1->math<0||p1->math>100)
{getchar();
printf("輸入錯誤,請重新輸入數學成績");
scanf("%f",&p1->math);}
}
end: p1=head;
p3=p1;
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p1;
p1=p1->next;
if(max->number>p1->number)
{
k=max->number;
max->number=p1->number;
p1->number=k;
strcpy(t,max->name);
strcpy(max->name,p1->name);
strcpy(p1->name,t);
fen=max->computer;
max->computer=p1->computer;
p1->computer=fen;
fen=max->english;
max->english=p1->english;
p1->english=fen;
fen=max->math;
max->math=p1->math;
p1->math=fen;
}
}
max=head;p1=head;/*重新使max,p指向鏈表頭*/
}
p2->next=NULL;/*鏈表結尾*/
printf("輸入的學生數為:%d個!\n",n);
return(head);
}
/*==============================================================================================*/
score *add2311(score *head,score *stu)/*函數add2311,功能將所有學生資料按學號排序*/
{
score *p0,*p1,*p2,*p3,*max;
int i,j;
float fen;
char t[10];
p3=stu=(score *)malloc(LEN);/*開辟一個新單元*/
printf("\n輸入要增加的學生的資料!");
repeat4: printf("請輸入學生學號(學號應大於0):");
scanf("%d",&stu->number);
/*輸入學號,學號應大於0*/
while(stu->number<0)
{getchar();
printf("輸入錯誤,請重新輸入學生學號:");
scanf("%d",&stu->number);}/*輸入錯誤,重新輸入學號*/
if(stu->number==0)
goto end2;/*當輸入的學號為0時,轉到末尾,結束追加*/
else
{
p3=head;
if(n>0)
{for(i=0;i<n;i++)
{if(stu->number!=p3->number)
p3=p3->next;
else
{printf("學號重復,請重輸!\n");
goto repeat4;
}
}
}
}
/******************************************************/
printf("輸入學生姓名:");
scanf("%s",stu->name);
printf("請輸入計算機 成績(0~100):");
scanf("%f",&stu->computer);
while(stu->computer<0||stu->computer>100)
{getchar();
printf("輸入錯誤,請重新輸入計算機 成績");
scanf("%f",&stu->computer);}
printf("請輸入英語成績(0~100):");
scanf("%f",&stu->english);
while(stu->english<0||stu->english>100)
{getchar();
printf("輸入錯誤,請重新輸入英語成績");
scanf("%f",&stu->english);}
printf("請輸入數學成績(0~100):");
scanf("%f",&stu->math);
while(stu->math<0||stu->math>100)
{getchar();
printf("輸入錯誤,請重新輸入數學成績");
scanf("%f",&stu->math);}
p1=head;
p0=stu;
if(head==NULL)
/*當原來鏈表為空時,從首結點開始存放資料*/
else
{
if(p1->next==NULL)
{
p1->next=p0;
p0->next=NULL;
}
else
{
while(p1->next!=NULL)
{
p2=p1;p1=p1->next;
}
p1->next=p0;
p0->next=NULL;
}
}
n=n+1;
p1=head;
p0=stu;
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p1;
p1=p1->next;
if(max->number>p1->number)
{
k=max->number;
max->number=p1->number;
p1->number=k;
strcpy(t,max->name);
strcpy(max->name,p1->name);
strcpy(p1->name,t);/*交換前後結點中的姓名,使之與學號相匹配*/
fen=max->computer;
max->computer=p1->computer;
p1->computer=fen;
fen=max->english;
max->english=p1->english;
p1->english=fen;
fen=max->math;
max->math=p1->math;
p1->math=fen;

}
}
max=head;p1=head;
} end2:
printf("現在的學生數為:%d個!\n",n);
return(head);
}
score *search(score *head)
/*函數search,功能:查詢學生成績*/
{int number;
score *p1,*p2;
printf("輸入要查詢的學生的學號,");
scanf("%d",&number);
while(number!=0)
{
if(head==NULL)

printf("-----------------------------------------\n");
printf("|學號\t|姓名\t|計算機\t|英語\t|數學\t|\n");
printf("-----------------------------------------\n");
p1=head;
while(number!=p1->number&&p1->next!=NULL)

if(number==p1->number)
{printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p1->number,p1->name,p1->computer,p1->english,p1->math);
printf("-----------------------------------------\n");}
else
printf("%d不存在此學生!\n",number);
printf("輸入要查詢的學生的學號,");
scanf("%d",&number);
}
printf("已經退出了!\n");
return(head);}
/*==============================================================================================*/
score *del(score *head)/*函數del,功能:刪除學生資料*/
{
score *p1,*p2;
int number;
printf("輸入要刪除的學生的學號(輸入0時退出):");
scanf("%d",&number);
getchar();
while(number!=0)/*輸入學號為0時退出*/
{
if(head==NULL)
{
printf("\n沒有任何學生資料!\n");
return(head);
}
p1=head;
while(number!=p1->number&&p1->next!=NULL)
{
p2=p1;p1=p1->next;
}
if(number==p1->number)
{
if(p1==head)
head=p1->next;
/*若p1指向的是首結點,把地二個結點地址賦予head*/
else
p2->next=p1->next;
printf("刪除:%d\n",number);n=n-1;
}
else
printf("%d不存在此學生!\n",number);
printf("輸入要刪除的學生的學號:");
scanf("%d",&number);
getchar();
}
#ifdef DEBUG
printf("已經退出了!\n");
#endif
printf("現在的學生數為:%d個!\n",n);
return(head);
}
/*==============================================================================================*/
void print(score *head)/*函數print,功能:顯示學生成績*/
{
score *p;
if(head==NULL)

else
{printf("%d\n",n);
printf("-----------------------------------------\n");
printf("|學號\t|姓名\t|計算機\t|英語\t|數學\t|\n");
printf("-----------------------------------------\n");
p=head;
do
{printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p->name,p->computer,p->english,p->math);
printf("-----------------------------------------\n");
p=p->next;}while (p!=NULL);
}
}
/*==============================================================================================*/
score *tongji(score *head)
/*函數tongji,功能:統計學生成績*/
{
float sum1=0,sum2=0,sum3=0,ave1=0,ave2=0,ave3=0,max=0,min;
score *p;
int x,y=0,i=0;
p=head;
printf("1個人總分和平均分\t2單科平均分\t3總分最高分\t4總分最低分\n");
scanf("%d",&x);
getchar();
switch(x)
{
case 1: if(head==NULL)

else
{
printf("---------------------------------------------------------\n");
printf("|學號\t|姓名\t|計算機\t|英語\t|數學\t|總分\t|平均分\t|\n");
printf("---------------------------------------------------------\n");
while(p!=NULL)
{
sum1=p->computer+p->english+p->math;
ave1=sum1/3;
printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p->name,p->computer,p->english,p->math,sum1,ave1);
printf("---------------------------------------------------------\n");/*列印表格域*/
p=p->next;}
}
return(head); break;
case 2: if(head==NULL)

while(p!=NULL)
{
sum1=sum1+p->computer;
sum2=sum2+p->english;
sum3=sum3+p->math;/*計算總分*/
y=y+1;
ave1=sum1/y;
ave2=sum2/y;
ave3=sum3/y;
p=p->next;
}
printf("計算機 平均分是%.1f\n",ave1);
printf("英語平均分是%.1f\n",ave2);
printf("數學平均分是%.1f\n",ave3);
return(head); break;
case 3:
if(head==NULL)

max=p->computer+p->english+p->math;
while(i<n)
{
i=i+1;
sum1=p->computer+p->english+p->math;
if(max<sum1)
max=sum1;
p=p->next;
}
printf("總分最高分:%.1f",max);
printf("\n");
return(head); break;
case 4: if(head==NULL)

while(p!=NULL)
{
min=p->computer+p->english+p->math;
while(p!=NULL)
{sum2=p->computer+p->english+p->math;
if(min>sum2)
min=sum2;
p=p->next;
}
}
printf("總分最低分:%.1f",min);
printf("\n");
return(head); break;
default :printf("輸入錯誤,請重試!\n");
}
return(head);
}
/*==============================================================================================*/
save(score *p1)
/*函數save,功能:保存學生的資料*/
{
FILE *fp;
char filepn[20];/*用來存放文件保存路徑以及文件名*/
printf("請輸入文件路徑及文件名:");
scanf("%s",filepn);
if((fp=fopen(filepn,"w+"))==NULL)
{
printf("不能打開文件!\n");
return 0;
}
fprintf(fp,"|學號\t|姓名\t|計算機\t|英語\t|數學\t|\n");
fprintf(fp,"-----------------------------------------\n");
while(p1!=NULL)
{
fprintf(fp,"%d\t%s\t%.1f\t%.1f\t%.1f\t\n",p1->number,p1->name,p1->computer,p1->english,p1->math);
p1=p1->next;
}
fclose(fp);
printf("文件已經保存!\n");
return 0;
}
/*==============================================================================================*/
score *paixu(score *head) /*定義排序函數。此函數帶回一個指向鏈表頭的指針*/
{ score *p,*max;
int i,j,x;
float fen;
char t[10];
if(head==NULL)
/*鏈表為空*/
max=p=head;
for(i=0;i<80;i++)
printf("*");
printf("1按學生學號排序\t2按學生姓名排序\t3按計算機 成績排序\n");
printf("4按英語成績排序\t5按數學成績排序\t\n");
for(i=0;i<80;i++)
printf("*");
printf("請選擇操作:");
scanf("%d",&x);/*選擇操作*/
getchar();
switch(x)
{case 1 :
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p;
p=p->next;

if(max->number>p->number)
{
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->english;
max->english=p->english;
p->english=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
}
}
max=head;p=head;/*重新使max,p指向鏈表頭*/
}
print(head);break;
case 2 : for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p;
p=p->next;
if(strcmp(max->name,p->name)>0)/*字元串比較*/
{
strcpy(t,max->name);/*字元串復制*/
strcpy(max->name,p->name);
strcpy(p->name,t);
k=max->number;
max->number=p->number;
p->number=k;
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->english;
max->english=p->english;
p->english=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
/*交換前後結點中的數學成績,使之與姓名相匹配*/
}
}
p=head;
max=head;
}
print(head);
break;

case 3 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->computer>p->computer)
{
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->english;
max->english=p->english;
p->english=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
}
}
p=head;
max=head;
}
print(head);
break;

case 4 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->english>p->english)
{
fen=max->english;
max->english=p->english;
p->english=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
}
}
p=head;
max=head;
}
print(head);
break;
case 5 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->math>p->math)
{
fen=max->math;
max->math=p->math;
p->math=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->english;
max->english=p->english;
p->english=fen;
}
}
p=head;
max=head;
}
print(head);
break;
default :printf("輸入錯誤,請重試! \n");
}
return (0);}
/*==============================================================================================*/
int menu(k)/*函數menu,功能:菜單選擇界面*/
{
int i;
printf("\t\t\t\t學生信息管理系統\n");
for(i=0;i<80;i++)
printf("*");
printf(" \t\t\t1添加學生記錄\t\t\t \n");
printf(" \t\t\t2.顯示學生記錄\t\t\t \n");
printf(" \t\t\t3.刪除學生記錄\t\t\t \n");
printf(" \t\t\t4.查詢學生記錄\t\t\t \n");
printf(" \t\t\t5.統計學生記錄\t\t\t \n");
printf(" \t\t\t6.排序\t\t\t \n");
printf(" \t\t\t7.保存學生記錄\t\t\t \n");
/*菜單選擇界面*/
for(i=0;i<80;i++)
printf("*");
printf("請選擇您所要的操作(選擇(0)退出):");
scanf("%d",&k);/*選擇操作*/
getchar();
return (k);}
main()
{score *head=0,*stu=0;
while(1)
{k=menu(k);
switch(k)/*用switch語句實現功能選擇*/
{case 1: head=creat();break;/*調用創建鏈表函數*/
case 2: print(head); break;/*調用顯示學生信息函數*/
case 3: head=del(head); break;/*調用刪除學生信息函數*/
case 4: head=search(head);break;/*調用成績查詢函數*/
case 5: tongji(head); break;/*調用統計函數*/
case 6: paixu(head);break;/*調用排序函數*/
case 7: save(head);break;/*調用保存函數*/
case 0: exit(0);/*退出系統,返回主界面*/
default: printf("輸入錯誤,請重試!\n"); }
}

自己套了修改!

③ 用visual C++做學生成績管理程序(MFC版)

上電驢搜索相關詞彙(如:visual C)你就會有意外的收獲。

④ 用MFC做一個學生成績管理系統連接SQL Server 2008

給你一個使用sql server2005的例子。

做得比較狠詳細的。

資源來自網路。

⑤ 要用MFC寫一個學生成績管理系統!!現在不知道怎麼和資料庫進行連接!

這類系統,自己不會的,要找人代做了,收點小錢

⑥ 求一個用MFC做的學生成績管理系統。初學者,希望一個簡單的可以用資料庫導入的學生成績管理系統。謝謝啦~~

有一個MFC做的資產管理系統 帶資料庫 需要不? 60個積分得給我哈

⑦ 怎麼用MFC做一個學生成績管理系統

第一:明確學生信息都有哪些?比如姓名,學號什麼的,放在一個類里回面
第二:學生信息的存答儲結構,我當時用的鏈表,寫出來鏈表的基本操作,比如刪除,遍歷,插入什麼的
第三:去實現你需要的功能,也就是定義實現功能函數,比如信息錄入什麼的,這個操作中就會用到我們第二步定義的鏈表的基本操作。
舉個例子: 我們要輸入學生信息,那你就要用鏈表的創建,插入,寫好直接調用就行。

⑧ 用C++ MFC以文件方式實現一個學生成績管理系統,功能實現增刪查改排序

在家挨罵fc even發的時間,那個學生的成績管理系統還可以掙錢,這對於喜歡的程度來說進不了人。

⑨ 我最近在用MFC編寫學生成績管理系統(對話框程序)。需要在登錄頁面自己成績管理頁面用到資料庫。可是

使用ADO連接資料庫
1、導入存放組件的庫文件。在stdafx.h文件中加入下列語句:
#import "c:\program Files\Common Files\system\ado\msado15.dll" no_namespace rename("EOF","EndOfFile") rename("BOF","FirstOfFile")
#include "icrsint.h"
ADO組件存放在msado15.dll文件中,導入該文件時,要重新定義EOF和BOF,以便與VC中ios.h、stdio.h中的EOF和BOF區別開來。
icrsint.h文件中包含了ADO控制項的聲明。
2、在應用程序類的InitInstance函數中加入:
AfxOleInit(); //初始化COM組件環境
3、為視圖類增加成員:
_ConnectionPtr m_myConnection; //連接對象
_RecordsetPtr m_myRSStudent; //記錄集
_RecordsetPtr m_myRS1; //記錄集
4、在修改視圖類的OnInitUpdate函數:
HRESULT hr;
try{hr = m_myConnection.CreateInstance("ADODB.Connection"); //創建連接實例if(SUCCEEDED(hr))hr =
m_myConnection->
Open("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=db1.mdb;", "", "",adModeUnknown);
//打開連接,連接到資料庫}
catch(_com_error e){
CString errormessage;
errormessage.Format("Connection failed\nInformation:%s",e.ErrorMessage());
AfxMessageBox(errormessage);}
m_myRSStudent.CreateInstance("ADODB.Recordset");
m_myRSStudent->Open(「select * from student」, //獲取數據的SQL語句m_myConnection.GetInterfacePtr(), //記錄集獲取數據時使用的連接adOpenDynamic,adLockOptimistic,adCmdText);//動態集、優化鎖、SQL命令形式
執行完這段代碼後,資料庫表student中的數據被提取到m_myRS所管理的內存區域。m_myRS1.CreateInstance("ADODB.Recordset");
m_myRS1->Open("select * from Class",
m_myConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
_variant_t vName; //變體數據類型,可以存放任意類型的數據
while(!m_myRS1->EndOfFile)
{vName = m_myRS1->GetCollect("ClassName");//獲取欄位內容m_TreeView.InsertItem((_bstr_t)vName); //填充TreeView
m_myRS1->MoveNext();}
m_ListView.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_ListView.InsertColumn(0,"學號",LVCFMT_CENTER,60);
m_ListView.InsertColumn(1,"姓名",LVCFMT_CENTER,60);
m_ListView.InsertColumn(2,"數學",LVCFMT_CENTER,60);
m_ListView.InsertColumn(3,"英語",LVCFMT_CENTER,60);
m_ListView.InsertColumn(4,"計算機",LVCFMT_CENTER,60);}

⑩ vc++ MFC 學生成績管理系統

嘿嘿,,謝謝!這個是我以前給別人寫的畢設,改代碼的話,現在可能不太方便,因為我這邊現在沒有環境。。不過你可以在網路hi我。。扣扣只有晚上有時間上,你可看看我的資料,加我扣扣,晚上咱們可以聊聊。

熱點內容
武漢大學學生會輔導員寄語 發布: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