| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2089 人关注过本帖
标题:求大神指导下。有个错误。
只看楼主 加入收藏
q9253
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-1-4
结帖率:0
收藏
已结贴  问题点数:20 回复次数:14 
求大神指导下。有个错误。
#include<stdio.h>                      /*I/O函数*/

#include<string.h>                      /*字符串函数*/

#include<stdlib.h>                       /*标准库函数*/

struct time                             /*定义时间结构*/

{

 int hour;                                        /*时*/

 int minute;                                      /*分*/

};

typedef struct STUDENT                /*定义学生信息结构*/

{

 int no;                                          /*学号*/

charcla[10];                                   /*班级*/
charname[10];                                   /*姓名*/

 inttime_hour;                             /*上机时间*/

 int time_minute;

 struct timebegin,end;                           /*嵌套时间结构*/

};

struct STUDENT student[30];

static int i =0;                           /*全局静态变量*/

void insert();                            /*输入功能函数*/

void end_money();                        /*结账功能函数*/

void select_no();                       /*学号查询功能函数*/

void select_name();                     /*姓名查询功能函数*/

void select_cla();                       /*班级查询功能函数*/

int main()                                      /*主函数*/
{

 int i;

 for(;;)                                      /*主菜单*/

 {

 printf("\t\t*********************************\n");

 printf("\t\t*********机房收费管理系统********\n");

   printf("\t\t*********************************\n");

 printf("1.---------------输入学生信息:\n");

 printf("2.---------------结账:\n");

 printf("3.---------------按学号查询:\n");

 printf("4.---------------按班级查询:\n");

 printf("5.---------------按姓名查询:\n");

 printf("6.---------------退出系统:\n");

 printf("\n\n^^^^^^^^^^^^^^^^^^^^^^^编程人员:*****^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
printf("\n\n请选择功能:");

 scanf("%d",&i);

 

switch(i)/*选择分支结构*/

 {

 case 1:                       

      {

            system("cls");

            insert();

      }break;

 case 2:

      {

            system("cls");

            end_money();

      }break;
case 3:

      {

            system("cls");

            select_no();

      }break;

 case 4:

      {

            system("cls");

            select_cla();

      }break;

 case 5:                 

      {

            system("cls");

            select_name();

      }break;
case 6:

      {

            return0;

      }

 }

 }

 system("pause");

  return 0;

}

void insert()                                  /*输入功能*/

{

   

      printf("请输入学号:");

      scanf("%d",&student[i].no);

      printf("请输入姓名:");

      scanf("%s",&student[i].name);

      printf("请输入班级:");
scanf("%s",&student[i].cla);

      printf("请输入上机时间:");

      scanf("%d:%d",&student[i].begin.hour,&student[i].begin.minute);

      i = i + 1;

      system("pause");

      system("cls");

      



}

void end_money()                              /*计算功能*/

{

 int m,minute,hour;                              /*保存时间*/

 int no;

 printf("请输入学号:");

 scanf("%d",&no);
for(m = 0;m <i;m++)

 {

      if(no ==student[m].no)

      {

            printf("请输入%d的下机时间:",no);

            scanf("%d:%d",&student[m].end.hour,&student[m].end.minute);

            if(student[m].end.minute<student[m].begin.minute)

            {

                  minute= student[m].end.minute +60 -student[m].begin.minute;

                  hour= student[m].end.hour -1 - student[m].begin.hour;

                  student[m].time_hour= hour;

                  student[m].time_minute= minute;

            

      

            }
  else

            {

                minute = student[m].end.minute - student[m].begin.minute;

                   hour = student[m].end.hour - student[m].begin.hour;

                   student[m].time_hour = hour;

                   student[m].time_minute = minute;

                  

            }

            if(minute> 0)

            {

                  hour= hour + 1;

                  printf("上机时间为:%d:%d  费用为:%d",student[m].time_hour,student[m].time_minute,hour);
}

            else

            {

               printf("上机时间为:%d:%d  费用为:%d",student[m].time_hour,student[m].time_minute,hour);

            }

 

 

      }

 }

 system("pause");

 system("cls");/*清屏*/

      

}
Void select_no()                                               /*按学号查询功能*/

{

    int no;

 int m;

 printf("请输入学号:");

 scanf("%d",&no);

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

 {

      if(no ==student[m].no)

      {

             printf("学号为%d\t",student[m].no);

             printf("班级为%s\t",student[m].cla);

             printf("姓名为%s\t",&student[m].name);

             printf("上机开始时间为%d:%d\t",student[m].begin.hour,student[m].begin.minute);

             printf("上机结束时间为%d:%d\t",student[m].end.hour,student[m].end.minute);

             printf("上机时间为:%d:%d\n\t",student[m].time_hour,student[m].time_minute);
}

      else if( m== i)

      {

            printf("没有该记录:\n");

      }

 

 }

 system("pause");

 system("cls");/*清屏*/

      

 

}   

void select_cla()                                                /*按班级查询功能*/

{

    charcla[10];

 int m;

 printf("请输入班级:");
scanf("%s",cla);

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

 {

      if(!strcmp(cla,student[m].cla))

      {

             printf("学号为%d\t",student[m].no);

             printf("班级为%s\t",student[m].cla);

             printf("姓名为%s\t",&student[m].name);

             printf("上机开始时间为%d:%d\t",student[m].begin.hour,student[m].begin.minute);

             printf("上机结束时间为%d:%d\t",student[m].end.hour,student[m].end.minute);

             printf("上机时间为:%d:%d\n",student[m].time_hour,student[m].time_minute);

      }

      else if( m== i)

      {

            printf("没有该记录:\n");

      }
}

 system("pause");

 system("cls");/*清屏*/

}  

void select_name()/*按姓名查询功能*/

{

    charname[10];

 int m;

 printf("请输入姓名:");

 scanf("%s",name);

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

 {

      if(!strcmp(name,student[m].name))/*字符串的比较  非0为真执行*/

      {

 

             printf("学号为%d\t",student[m].no);

             printf("班级为%s\t",student[m].cla);
 printf("姓名为%s\t",&student[m].name);

             printf("上机开始时间为%d:%d\t",student[m].begin.hour,student[m].begin.minute);

             printf("上机结束时间为%d:%d\t",student[m].end.hour,student[m].end.minute);

             printf("上机时间为:%d:%d\n",student[m].time_hour,student[m].time_minute);

      }

      else if( m== i)

      {

            printf("没有该记录:\n");

      }

 }

 system("pause");

 system("cls");/*清屏*/

}
搜索更多相关主题的帖子: 结构 时间 include minute 字符串 
2013-01-04 10:33
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:3 
说清楚什么错误,有错误信息吗?

总有那身价贱的人给作业贴回复完整的代码
2013-01-04 10:36
q9253
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-1-4
收藏
得分:0 
回复 2楼 embed_xuel
机房计费.c
D:\VC编程\\机房计费.c(23) : error C2061: syntax error : identifier 'charcla'
D:\VC编程\\机房计费.c(30) : error C2059: syntax error : ','
D:\VC编程\\机房计费.c(32) : error C2059: syntax error : '}'
D:\VC编程\\机房计费.c(34) : error C2133: 'student' : unknown size
D:\VC编程\\机房计费.c(138) : error C2065: 'return0' : undeclared identifier
D:\VC编程\\机房计费.c(160) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(160) : error C2037: left of 'no' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(164) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(164) : error C2037: left of 'name' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(167) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(167) : error C2037: left of 'cla' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(171) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(171) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(171) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(171) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(200) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(200) : error C2037: left of 'no' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(206) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(206) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(206) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(206) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(208) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(208) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(208) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(208) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(212) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(212) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(212) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(212) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(214) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(214) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(214) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(214) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(216) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(216) : error C2037: left of 'time_hour' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(218) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(218) : error C2037: left of 'time_minute' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(229) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(229) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(229) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(229) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(231) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(231) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(231) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(231) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(233) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(233) : error C2037: left of 'time_hour' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(235) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(235) : error C2037: left of 'time_minute' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(247) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(247) : error C2037: left of 'time_hour' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(247) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(247) : error C2037: left of 'time_minute' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(254) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(254) : error C2037: left of 'time_hour' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(254) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(254) : error C2037: left of 'time_minute' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(273) : error C2061: syntax error : identifier 'select_no'
D:\VC编程\\机房计费.c(273) : error C2059: syntax error : ';'
D:\VC编程\\机房计费.c(273) : error C2059: syntax error : ')'
D:\VC编程\\机房计费.c(332) : error C2065: 'charcla' : undeclared identifier
D:\VC编程\\机房计费.c(332) : error C2109: subscript requires array or pointer type
D:\VC编程\\机房计费.c(334) : error C2143: syntax error : missing ';' before 'type'
D:\VC编程\\机房计费.c(337) : error C2065: 'cla' : undeclared identifier
D:\VC编程\\机房计费.c(339) : error C2065: 'm' : undeclared identifier
D:\VC编程\\机房计费.c(343) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
D:\VC编程\\机房计费.c(343) : warning C4024: 'strcmp' : different types for formal and actual parameter 1
D:\VC编程\\机房计费.c(343) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(343) : error C2037: left of 'cla' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(343) : error C2198: 'strcmp' : too few actual parameters
D:\VC编程\\机房计费.c(347) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(347) : error C2037: left of 'no' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(349) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(349) : error C2037: left of 'cla' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(351) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(351) : error C2037: left of 'name' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(353) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(353) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(353) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(353) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(355) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(355) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(355) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(355) : error C2037: left of 'end' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(357) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(357) : error C2037: left of 'time_hour' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(357) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(357) : error C2037: left of 'time_minute' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(382) : error C2143: syntax error : missing ';' before 'type'
D:\VC编程\\机房计费.c(386) : error C2065: 'name' : undeclared identifier
D:\VC编程\\机房计费.c(392) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
D:\VC编程\\机房计费.c(392) : warning C4024: 'strcmp' : different types for formal and actual parameter 1
D:\VC编程\\机房计费.c(392) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(392) : error C2037: left of 'name' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(392) : error C2198: 'strcmp' : too few actual parameters
D:\VC编程\\机房计费.c(398) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(398) : error C2037: left of 'no' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(400) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(400) : error C2037: left of 'cla' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(401) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(401) : error C2037: left of 'name' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(403) : error C2036: 'struct STUDENT *' : unknown size
D:\VC编程\\机房计费.c(403) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC
D:\VC编程\\机房计费.c(403) : error C2037: left of 'begin' specifies undefined struct/union 'STUDENT'
D:\VC编程\\机房计费.c(403) : fatal error C1003: error count exceeds 100; stopping compilation
执行 cl.exe 时出错.
2013-01-04 10:45
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:0 
变量类型和名字没有用空格格开
charcla[10];                                   /*班级*/charname[10];                                   /*姓名*/inttime_hour;                             /*上机时间*/

总有那身价贱的人给作业贴回复完整的代码
2013-01-04 11:11
q9253
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-1-4
收藏
得分:0 
回复 4楼 embed_xuel
   急死我了。还是有错。
2013-01-04 11:21
阿鞠尼
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:首尔
等 级:蒙面侠
威 望:5
帖 子:1467
专家分:4442
注 册:2012-5-30
收藏
得分:3 
以下是引用q9253在2013-1-4 10:33:07的发言:

#include                      /*I/O函数*/

#include                      /*字符串函数*/

#include                       /*标准库函数*/

struct time                             /*定义时间结构*/

{

 int hour;                                        /*时*/

 int minute;                                      /*分*/

};

typedef struct STUDENT                /*定义学生信息结构*/

{

 int no;                                          /*学号*/

charcla[10];                                   /*班级*/
charname[10];                                   /*姓名*/


inttime_hour;                             /*上机时间*/

 int time_minute;

struct timebegin,end;                           /*嵌套时间结构*/

};

struct STUDENT student[30];

static int i =0;                           /*全局静态变量*/

void insert();                            /*输入功能函数*/

void end_money();                        /*结账功能函数*/

void select_no();                       /*学号查询功能函数*/

void select_name();                     /*姓名查询功能函数*/

void select_cla();                       /*班级查询功能函数*/

int main()                                      /*主函数*/
{

 int i;

 for(;;)                                      /*主菜单*/

 {

 printf("\t\t*********************************\n");

 printf("\t\t*********机房收费管理系统********\n");

   printf("\t\t*********************************\n");

 printf("1.---------------输入学生信息:\n");

 printf("2.---------------结账:\n");

 printf("3.---------------按学号查询:\n");

 printf("4.---------------按班级查询:\n");

 printf("5.---------------按姓名查询:\n");

 printf("6.---------------退出系统:\n");

 printf("\n\n^^^^^^^^^^^^^^^^^^^^^^^编程人员:*****^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
printf("\n\n请选择功能:");

 scanf("%d",&i);

 

switch(i)/*选择分支结构*/

 {

 case 1:                       

      {

            system("cls");

            insert();

      }break;

 case 2:

      {

            system("cls");

            end_money();

      }break;
case 3:

      {

            system("cls");

            select_no();

      }break;

 case 4:

      {

            system("cls");

            select_cla();

      }break;

 case 5:                 

      {

            system("cls");

            select_name();

      }break;
case 6:

      {

            return0;

      }

 }

 }

 system("pause");

  return 0;

}

void insert()                                  /*输入功能*/

{

   

      printf("请输入学号:");

      scanf("%d",&student.no);

      printf("请输入姓名:");

      scanf("%s",&student.name);

      printf("请输入班级:");
scanf("%s",&student.cla);

      printf("请输入上机时间:");

      scanf("%d:%d",&student.begin.hour,&student.begin.minute);

      i = i + 1;

      system("pause");

      system("cls");

      



}

void end_money()                              /*计算功能*/

{

 int m,minute,hour;                              /*保存时间*/

 int no;

 printf("请输入学号:");

 scanf("%d",&no);
for(m = 0;m
自己看看红色部分

喜欢睡觉 却经常熬夜
2013-01-04 11:36
阿鞠尼
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:首尔
等 级:蒙面侠
威 望:5
帖 子:1467
专家分:4442
注 册:2012-5-30
收藏
得分:0 
擦 只显示一部分怎么  错误按照提示自己慢慢找  很简单

喜欢睡觉 却经常熬夜
2013-01-04 11:37
q9253
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-1-4
收藏
得分:0 
回复 7楼 阿鞠尼
帮我 找出来吧,明天要用的。看的头都大了,自己还没电脑都是借用同学的。
2013-01-04 14:50
阿鞠尼
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:首尔
等 级:蒙面侠
威 望:5
帖 子:1467
专家分:4442
注 册:2012-5-30
收藏
得分:0 
回复 8楼 q9253
你自己按照编译器的提示 一步一步找就Ok了 我也没有电脑啊  

喜欢睡觉 却经常熬夜
2013-01-04 18:23
ksddah
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:53
专家分:135
注 册:2012-12-11
收藏
得分:3 
程序代码:
#include<stdio.h>                      /*I/O函数*/

#include<string.h>                      /*字符串函数*/

#include<stdlib.h>                       /*标准库函数*/

struct time                             /*定义时间结构*/

{

int hour;                                        /**/

int minute;                                      /**/

};

typedef struct STUDENT                /*定义学生信息结构*/

{

int no;                                          /*学号*/

char cla[10];                                   /*班级*/
char name[10];                                   /*姓名*/

int time_hour;                             /*上机时间*/

int time_minute;

struct time begin,end;                           /*嵌套时间结构*/

};

struct STUDENT student[30];

static int i =0;                           /*全局静态变量*/

void insert();                            /*输入功能函数*/

void end_money();                        /*结账功能函数*/

void select_no();                       /*学号查询功能函数*/

void select_name();                     /*姓名查询功能函数*/

void select_cla();                       /*班级查询功能函数*/

int main()                                      /*主函数*/
{

int i;

for(;;)                                      /*主菜单*/

{

printf("\t\t*********************************\n");

printf("\t\t*********机房收费管理系统********\n");

   printf("\t\t*********************************\n");

printf("1.---------------输入学生信息:\n");

printf("2.---------------结账:\n");

printf("3.---------------按学号查询:\n");

printf("4.---------------按班级查询:\n");

printf("5.---------------按姓名查询:\n");

printf("6.---------------退出系统:\n");

printf("\n\n^^^^^^^^^^^^^^^^^^^^^^^编程人员:*****^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
printf("\n\n请选择功能:");

scanf("%d",&i);



switch(i)/*选择分支结构*/

{

case 1:                       

      {

            system("cls");

            insert();

      }break;

case 2:

      {

            system("cls");

            end_money();

      }break;
case 3:

      {

            system("cls");

            select_no();

      }break;

case 4:

      {

            system("cls");

            select_cla();

      }break;

case 5:                 

      {

            system("cls");

            select_name();

      }break;
case 6:

      {

            return 0;

      }

}

}

system("pause");

  return 0;

}

void insert()                                  /*输入功能*/

{

    

      printf("请输入学号:");

      scanf("%d",&student[i].no);

      printf("请输入姓名:");

      scanf("%s",&student[i].name);

      printf("请输入班级:");
scanf("%s",&student[i].cla);

      printf("请输入上机时间:");

      scanf("%d:%d",&student[i].begin.hour,&student[i].begin.minute);

      i = i + 1;

      system("pause");

      system("cls");

      



}

void end_money()                              /*计算功能*/

{

int m,minute,hour;                              /*保存时间*/

int no;

printf("请输入学号:");

scanf("%d",&no);
for(m = 0;m <i;m++)

{

      if(no ==student[m].no)

      {

            printf("请输入%d的下机时间:",no);

            scanf("%d:%d",&student[m].end.hour,&student[m].end.minute);

            if(student[m].end.minute<student[m].begin.minute)

            {

                  minute= student[m].end.minute +60 -student[m].begin.minute;

                  hour= student[m].end.hour -1 - student[m].begin.hour;

                  student[m].time_hour= hour;

                  student[m].time_minute= minute;

            

      

            }
  else

            {

                minute = student[m].end.minute - student[m].begin.minute;

                   hour = student[m].end.hour - student[m].begin.hour;

                   student[m].time_hour = hour;

                   student[m].time_minute = minute;

                   

            }

            if(minute> 0)

            {

                  hour= hour + 1;

                  printf("上机时间为:%d:%d  费用为:%d",student[m].time_hour,student[m].time_minute,hour);
}

            else

            {

               printf("上机时间为:%d:%d  费用为:%d",student[m].time_hour,student[m].time_minute,hour);

            }





      }

}

system("pause");

system("cls");/*清屏*/

      

}
void select_no()                                               /*按学号查询功能*/

{

    int no;

int m;

printf("请输入学号:");

scanf("%d",&no);

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

{

      if(no ==student[m].no)

      {

             printf("学号为%d\t",student[m].no);

             printf("班级为%s\t",student[m].cla);

             printf("姓名为%s\t",&student[m].name);

             printf("上机开始时间为%d:%d\t",student[m].begin.hour,student[m].begin.minute);

             printf("上机结束时间为%d:%d\t",student[m].end.hour,student[m].end.minute);

             printf("上机时间为:%d:%d\n\t",student[m].time_hour,student[m].time_minute);
}

      else if( m== i)

      {

            printf("没有该记录:\n");

      }



}

system("pause");

system("cls");/*清屏*/

      



}   

void select_cla()                                                /*按班级查询功能*/

{

    char cla[10];

int m;

printf("请输入班级:");
scanf("%s",cla);

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

{

      if(!strcmp(cla,student[m].cla))

      {

             printf("学号为%d\t",student[m].no);

             printf("班级为%s\t",student[m].cla);

             printf("姓名为%s\t",&student[m].name);

             printf("上机开始时间为%d:%d\t",student[m].begin.hour,student[m].begin.minute);

             printf("上机结束时间为%d:%d\t",student[m].end.hour,student[m].end.minute);

             printf("上机时间为:%d:%d\n",student[m].time_hour,student[m].time_minute);

      }

      else if( m== i)

      {

            printf("没有该记录:\n");

      }
}

system("pause");

system("cls");/*清屏*/

}  

void select_name()/*按姓名查询功能*/

{

    char name[10];

     int m;

     printf("请输入姓名:");

     scanf("%s",name);

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

{

      if(!strcmp(name,student[m].name))/*字符串的比较  非0为真执行*/

      {



             printf("学号为%d\t",student[m].no);

             printf("班级为%s\t",student[m].cla);
             printf("姓名为%s\t",&student[m].name);

             printf("上机开始时间为%d:%d\t",student[m].begin.hour,student[m].begin.minute);

             printf("上机结束时间为%d:%d\t",student[m].end.hour,student[m].end.minute);

             printf("上机时间为:%d:%d\n",student[m].time_hour,student[m].time_minute);

      }

      else if( m== i)

      {

            printf("没有该记录:\n");

      }

}

system("pause");

system("cls");/*清屏*/

}
2013-01-04 19:20
快速回复:求大神指导下。有个错误。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039999 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved