• 大小: 10KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-05-15
  • 语言: C/C++
  • 标签: C语言  课程设计  

资源简介

c语言课程设计,学生选课管理系统,编译环境DevC++ 1. 本次课设小组已达到课程目的。主要熟悉C语言中结构体、指针、文件的使用。加深对C语言基础知识的理解和掌握,并规范编程习惯,进一步增强C语言编程实践能力,锻炼思维逻辑和解决综合性实际问题的能力, 2. 加深对C语言的理解,为接下来的学习打下坚实的基础。 3. 对于想大作业这样的工作量,一个人是很难以去完成的,通过这次大作业,充分的锻练了我们的合作能力,以及在编程的过程中要考虑的程序的适用性,而不是像平时作业一样任凭自己发挥。

资源截图

代码片段和文件信息

#include
#include
#include
#include 
struct subject{//课程信息 
int number;//课程编码 
char name[20];//课程名称 
char teacher[20];//教师姓名 
int point;//课程学分 
char place[20];//教室地点   
};
struct system{//用户账号信息 
long count;
long password;
};
struct student{//账号数据 
int count;//账号 
char name[20];//姓名 
char selectclass[20];//选课1 
char selectclass2[20];//选课2 
};
void subjects()//显示学科数据 
{
FILE *fp;
struct subject st1[128];
int ilen;

fp=fopen(“课程数据.txt““rb“);
if (fp==NULL) 
{
printf(“can‘t open file\n“);
exit(0);
}
for(i=0;!feof(fp);i++)
fread(st1sizeof(struct subject)1fp);
rewind(fp);
len=i-1;
printf(“序号: 课程   老师   学分 地点\n“);
fread(st1sizeof(struct subject)lenfp);
for(i=0;i printf(“%d   : %s   %s   %d    %s  \n“st1[i].numberst1[i].namest1[i].teacherst1[i].pointst1[i].place);
fclose(fp);
}
long login()//用户登入 
{
FILE *fp;
struct system user[128];
int i;
long count;
long password;
int sele; 

printf(“-----------欢迎使用学生选课管理系统-----------\n“);
printf(“\n“); 
fp=fopen(“用户信息.txt““r“);
if (fp==NULL) 
{
printf(“can‘t open file\n“);
exit(0);
}
for(i=0;i<4;i++)
{
fscanf(fp“%d %d “&user[i].count&user[i].password);
}

printf(“请输入账号(提示:账号形式为100**数据类型为整形):“);
do//账号输入 
{
scanf(“%d“&count);
for(i=0;i<4;i++)
{
if(user[i].count==count)
break;
}
if(i==4)
printf(“账号输入错误,请重新输入:“);
}while(i==4); 

printf(“请输入密码(数据类型为整形):“);

do//密码输入 
{
scanf(“%d“&password);
if(password==user[i].password)    
break;
printf(“密码输入错误,请重新输入:“);
}while(password!=user[i].password);

return count;
}
/////////////////////////////////////////////////////////////////学生功能代码 
void choose1()//第一次选课 
{
int seleilent=0;
FILE *fp;
struct subject st1[128];
void loadclass1( int number);

fp=fopen(“课程数据.txt““rb“);
if (fp==NULL) 
{
printf(“can‘t open file\n“);
exit(0);

for(i=0;!feof(fp);i++)
fread(st1sizeof(struct subject)1fp);
rewind(fp);
len=i-1;
fread(st1sizeof(struct subject)lenfp);

printf(“--------------一次选课-----------------\n“);
printf(“课程如下\n“);
subjects();
printf(“如果你想选择课程,请输入前面的序号:“);
do
{
scanf(“%d“&sele);
for(i=0;i {
if(sele==st1[i].number)
{
loadclass1(sele);
t=9;
}
}
if(t==9)
break;
printf(“输入错误,请重新输入:“); 
}while(t!=9);
}
void choose2()//第二次选课 
{
int seleilent=0;
FILE *fp;
struct subject st1[128];
void loadclass2( int number);
fp=fopen(“课程数据.txt““r“);
if (fp==NULL) 
{
printf(“can‘t open file\n“);
exit(0);
}
for(i=0;!feof(fp);i++)
fread(st1sizeof(struct subject)1fp);
rewind(fp);
len=i-1;
fread(st1sizeof(struct subject)lenfp);
printf(“课程如下\n“);
subjects();
printf(“如果你想选择课程,请输入前面的序号:“);
do
{
scanf(“%d“&sele);
for(i=0;i {
if(sele==st1[i].number)
{
loadclass2(sele);

评论

共有 条评论