資源簡介
C語言程序設計—學生學籍信息管理系統,功能能全部實現,用C語言寫的代碼能在VC++的環境里運行
代碼片段和文件信息
//#include?“bios.h“?????/*基本輸入輸出系統函數庫*/
#include?“math.h“???????/*數學運算函數庫*/
#include?“stdio.h“??????/*標準輸入輸出函數庫*/
#include?“stdlib.h“?????/*標準函數庫*/
#include?“string.h“?????/*字符串函數庫*/
#include?“conio.h“??????/*屏幕操作函數庫*/
#include?“dos.h“????????/*與日期獲得有關*/
struct?course
{
?char?stuNo[8];
?char?courseNo[6]; //課程代號
?char?courseName[10];???//課程名字
?float?creditHour; //學分
?float?triGrade;????????//平時成績
?float?experiGrade; //實驗成績
?float?examGrade; //卷面成績
?float?totalGrade; //綜合成績
?float?finalCreHour; //實際學分
}course_datas_course[100];
struct?info?
{?
int?sMingci;? //名次
char?stuNo[8];??????????//學號
char?name[10]; //姓名
char?sex[2]; //性別
char?domNum[4]; //宿舍號
char?tel[9];?? //宿舍電話號碼
}datas_info[100];
int?ijk=0;?
int?ab;
int?flag=0;
char?temp[20]chch1ch2;?
char?temp_NO[8]temp_name[10]temp_dnum[4];
char?tempcn[6];
char?sn[8]; //臨時學號
float?z_fenfinalCreHour;
struct?course?temp_course;
struct?info?*inf;
FILE?*fp*fp1*fp2;?
void?input()????//輸入數據
{?
while(1)
{
printf(“\n請輸入增加學生的方式:?1(按學號增加學生)??2(按分數增加學生)??e(退出):“);
printf(“%c“ch);
ch=getch();printf(“%c“ch);
if(ch==‘1‘)
{?
if((fp=fopen(“s_info.txt““at+“))==NULL)
{?
printf(“不能打開這個文件.\n“);?
getch();exit(0);?
}?
printf(“\n??????請輸入學生學號:“);?
gets(sn);
while((fread(&datasizeof(data)1fp))==1)?
{
if(strcmp(sndata.stuNo)==0)
{
flag=1;
}
}
if(flag==1)
{
printf(“\n?這個學號已經存在請輸入另外的學號:\n“);
flag=0;
getch();
continue;
}
else
{
strcpy(data.stuNosn);
}
?
printf(“??????請輸入學生姓名:“);?
gets(data.name);
?
printf(“??????請輸入學生性別:M(男生)/F(女生):“);?
gets(data.sex);
printf(“??????請輸入學生的寢室號:“);?
gets(data.domNum);
printf(“??????請輸入學生電話號碼:“);?
gets(data.tel);
fwrite(&datasizeof(data)1fp);?//寫入數據
fclose(fp);
?system(“cls“);?
}?????//if
?
else?if(ch==‘2‘)
{
?????if((fp1=fopen(“s_score.txt““at+“))==NULL||(fp=fopen(“s_info.txt““rt“))==NULL)
?{?
printf(“不能打開這個文件.\n“);?
getch();exit(0);?
}?
printf(“\n請輸入學生學號:“);?
gets(sn);
while((fread(&datasizeof(data)1fp))==1)?
{
if(strcmp(sndata.stuNo)==0)
{ flag=1;
}
}
if(!flag)
{ printf(“\nthis?number?is?not?exist\n“);
continue;
}
else
{?flag=0;
strcpy(course_data.stuNosn);
}
printf(“\n請輸入課程號:“);?
gets(course_data.courseNo);
printf(“\n請輸入課程名稱:“);?
gets(course_data.courseName);
printf(“\n請輸入課程學分:“);?
gets(temp);
course_data.creditHour=atof(temp);
printf(“\n請輸入平時成績:“);?
gets(temp);
course_data.triGrade=atof(temp);
printf(“\n請輸入實驗成績:“);?
gets(temp);
course_data.experiGrade=atof(temp);
printf(“\n請輸入卷面成績:“);?
gets(temp);
course_data.examGrade=atof(temp);
//以下是綜合成績計算
if(course_data.experiGrade==-1)?//如果有實驗
{
??course_data
- 上一篇:C++排課程序
- 下一篇:Kinect2.0采集圖像幀并保存
評論
共有 條評論