c语言程序课程设计

 3《机房收费管理系统》设计任务
(1)输入功能:输入30名学生的学号、班级、姓名、上机起止时间。
(2)计算功能:计算每个学生的上机费用。
(上机费用=上机时间* 1.0/h ,不足一小时按一小时计算)
(3)查询功能:按条件(班级、学号、姓名、上机时间)显示学生信息。
要求 模块化程序设计 锯齿型程序书写格式
求哪位高手帮帮忙 知道的告诉下!
简单你就帮我做一个啊!

#include<time.h>
#include<stdio.h>
#include<string.h>
#include<Windows.h>
#define N 20
#define M 100
struct student
{
char id[N];
char theclass[N];
char name[N];
char ontime[N];
}student[M];
int n;

void addition()
{
int i;
printf("\n请输入录入学生信息的总数:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n\t请输入第%d个学生学号(20s):",i);
scanf("%s",student[i-1].id);
printf("\n\t请输入第%d个学生班级(20s):",i);
scanf("%s",student[i-1].theclass);
printf("\n\t请输入第%d个学生姓名(20s):",i);
scanf("%s",student[i-1].name);
printf("\n\t请输入第%d个学生上机时间(20s)(例08:02):",i);
scanf("%s",student[i-1].ontime);
printf("\n\t提示:您已成功录入第%d条信息\n",i);
}
}

void calculate()
{
int hours;
char times[30];
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime(&rawtime );
strcpy(times,asctime(timeinfo));
printf("\t所有学生上机费用如下:\n");
for(int i=1;i<=n;i++)
{
printf("学生%d费用:",i);
if((student[i-1].ontime[3]-48)*10+student[i-1].ontime[4]>(times[14]-48)*10+times[15])
hours=(times[11]-48)*10+times[12]-(student[i-1].ontime[0]-48)*10-student[i-1].ontime[1];
else
hours=(times[11]-48)*10+times[12]-(student[i-1].ontime[0]-48)*10-student[i-1].ontime[1]+1;
printf("%d\n",hours);
}
}

void search()
{
int i,b,c,count;
do
{
char find[20];
printf("\n请选择查询方式:1.根据学号查询;2.根据班级查询;3.根据姓名查询;4.根据上机时间:");
scanf("%d",&b);
switch(b)
{
case 1:
count=PF_FLOATING_POINT_PRECISION_ERRATA;
printf("\n**请输入学生的学号:");
scanf("%s",find);
for(i=0;i<n;i++)
{
if (strcmp(student[i].id,find)==0)
{
count++;
if(count==PF_FLOATING_POINT_EMULATED)
printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,
student[i].name,student[i].ontime);
}
}
if(!count)
printf("****提示:该生不存在");
goto A;
case 2:
count=PF_FLOATING_POINT_PRECISION_ERRATA;
printf("\n**请输入学生的班级:");
scanf("%s",find);
for(i=0;i<n;i++)
{
if (strcmp(student[i].theclass,find)==0)
{
count++;
if(count==PF_FLOATING_POINT_EMULATED)
printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,
student[i].name,student[i].ontime);
}
}
if(!count)
printf("****提示:该生不存在");
goto A;
case 3:
count=PF_FLOATING_POINT_PRECISION_ERRATA;
printf("\n**请输入学生的姓名:");
scanf("%s",find);
for(i=0;i<n;i++)
{
if (strcmp(student[i].name,find)==0)
{
count++;
if(count==PF_FLOATING_POINT_EMULATED)
printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,
student[i].name,student[i].ontime);
}
}
if(!count)
printf("****提示:该生不存在");
goto A;
case 4:
count=PF_FLOATING_POINT_PRECISION_ERRATA;
printf("\n**请输入学生的上机时间:");
scanf("%s",find);
for(i=0;i<n;i++)
{
if (strcmp(student[i].ontime,find)==0)
{
count++;
if(count==PF_FLOATING_POINT_EMULATED)
printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,
student[i].name,student[i].ontime);
}
}
if(!count)
printf("****提示:该生不存在");
goto A;
default:printf("*****提示:输入错误");
}
A:printf("\n\t**1.继续\n\t**0.返回主菜单");
printf("\n\t 请输入您的选择:");
scanf("%d",&c);
}while(c);
}

void menu()
{
printf("\n\t*******************欢迎进入机房收费管理系统!*******************\n");
printf("\t* 1.录入功能 2.计算功能 *\n");
printf("\t* 3.查询功能 0.-*EXIT*- *\n");
printf("\t***************************************************************\n");
printf("\n\t 请输入您的选择:");
}

void main()
{
system("color 5f");
int a;
C:menu();
scanf("%d",&a);
switch(a)
{
case 0:printf("***正在退出**谢谢使用本系统,再见");break;
case 1:addition();goto C; /*录入功能*/
case 2:calculate();goto C; /*浏览功能*/
case 3:search();goto C; /*查询功能*/
}
}
看看满意不
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-06-22
这个设计比较简单吧 用结构体就行啦本回答被提问者采纳
相似回答