鱼C论坛

 找回密码
 立即注册
查看: 2754|回复: 7

[已解决]求助一个机房收费管理系统的源代码

[复制链接]
发表于 2019-6-10 14:47:54 From FishC Mobile | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
虽然知道这样直接伸手不太好
没有大佬提供的话那就自己打了
来自: 微社区
最佳答案
2019-6-11 21:01:35
  1. printf("\n\t请输入第%d个学生学号:",i);
  2.                 scanf("%s",student[i-1].id);
  3.                 printf("\n\t请输入第%d个学生班级:",i);
  4.                 scanf("%s",student[i-1].theclass);
  5.                 printf("\n\t请输入第%d个学生学号:",i);
  6.                 scanf("%s",student[i-1].name);
  7.                 printf("\n\t请输入第%d个学生学号:",i);
  8.                 scanf("%s",student[i-1].ontime);
复制代码

因为你把时间和姓名写成了学号
中途退出功能你可以设置一个特殊按键,若输入为该按键时回到主界面。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-6-10 15:19:08 | 显示全部楼层
那就自己打吧

点评

行吧  发表于 2019-6-10 15:27
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-6-10 16:00:05 | 显示全部楼层
你先打,我帮你改bug

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-11 20:05:11 | 显示全部楼层
TOP_LK 发表于 2019-6-10 16:00
你先打,我帮你改bug
  1. #include<time.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<Windows.h>
  5. #define N 20
  6. #define M 100
  7. struct student
  8. {
  9.         char id[N];
  10.         char theclass[N];
  11.         char name[N];
  12.         char ontime[N];
  13. } student[M];
  14. int n;
  15. void addition()
  16. {
  17.         int i;
  18.         printf("\n请输入入录学生信息在总数:");
  19.         scanf("%d",&n);
  20.         for(i=1;i<=n;i++)
  21.         {
  22.                 printf("\n\t请输入第%d个学生学号:",i);
  23.                 scanf("%s",student[i-1].id);
  24.                 printf("\n\t请输入第%d个学生班级:",i);
  25.                 scanf("%s",student[i-1].theclass);
  26.                 printf("\n\t请输入第%d个学生学号:",i);
  27.                 scanf("%s",student[i-1].name);
  28.                 printf("\n\t请输入第%d个学生学号:",i);
  29.                 scanf("%s",student[i-1].ontime);
  30.                 printf("\n\t提示:您已经成功录入第%d条信息\n",i);
  31.         }
  32. }
  33. void calculate()
  34. {
  35.         int hours;
  36.         char times[30];time_t rawtime;
  37.         struct tm*timeinfo;
  38.         time(&rawtime);
  39.         timeinfo=localtime(&rawtime);
  40.         strcpy(times,asctime(timeinfo));
  41.         printf("\t所有学生上机费用如下:\n");
  42.         for(int i=1;i<=n;i++)
  43.         {
  44.                 printf("学生%d费用:",i);
  45.                 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];
  46.                 else
  47.                         hours=(times[11]-48)*10+times[12]-(student[i-1].ontime[0]-48)*10-student[i-1].ontime[1]+1;
  48.                 printf("%d\n",hours);
  49.         }
  50. }
  51. void search()
  52. {
  53.         int i,b,c,count;
  54.         do
  55.         {
  56.                 char find[20];
  57.                 printf("\n请选择查询方式:1.根据学号查询;2.根据班级查询;3.根据姓名查询;4.根据上机时间:");
  58.                 scanf("%d",&b);
  59.                 switch(b)
  60.                 {
  61.                         case 1 : count=PF_FLOATING_POINT_PRECISION_ERRATA;
  62.                                          printf("\n**请输入学生的学号:");
  63.                                          scanf("%s",find);
  64.                                          for(i=0;i<n;i++)
  65.                                          {
  66.                                                 if(strcmp(student[i].id,find)==0)
  67.                                                 {
  68.                                                 count++;
  69.                                                 if (count==PF_FLOATING_POINT_EMULATED)
  70.                                                         printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
  71.                                                 printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,student[i].name,student[i].ontime);
  72.                                                 }
  73.                                          }
  74.                                          if(!count)
  75.                                                  printf("****提示:该学生不存在");
  76.                                          goto A;
  77.                         case 2 :count=PF_FLOATING_POINT_PRECISION_ERRATA;
  78.                                 printf("\n**请输入学生的班级:");
  79.                                 scanf("%s",find);
  80.                                 for(i=0;i<n;i++)
  81.                                          {
  82.                                                 if(strcmp(student[i].id,find)==0)
  83.                                                 {
  84.                                                 count++;
  85.                                                 if (count==PF_FLOATING_POINT_EMULATED)
  86.                                                         printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
  87.                                                 printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,student[i].name,student[i].ontime);
  88.                                                 }
  89.                                          }
  90.                                          if(!count)
  91.                                                  printf("****提示:该学生不存在");
  92.                                          goto A;
  93.                                 case 3 :count=PF_FLOATING_POINT_PRECISION_ERRATA;
  94.                                 printf("\n**请输入学生的姓名:");
  95.                                 scanf("%s",find);
  96.                                 for(i=0;i<n;i++)
  97.                                          {
  98.                                                 if(strcmp(student[i].id,find)==0)
  99.                                                 {
  100.                                                 count++;
  101.                                                 if (count==PF_FLOATING_POINT_EMULATED)
  102.                                                         printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
  103.                                                 printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,student[i].name,student[i].ontime);
  104.                                                 }
  105.                                          }
  106.                                          if(!count)
  107.                                                  printf("****提示:该学生不存在");
  108.                                          goto A;
  109.                                 case 4 :count=PF_FLOATING_POINT_PRECISION_ERRATA;
  110.                                 printf("\n**请输入学生的上机时间:");
  111.                                 scanf("%s",find);
  112.                                 for(i=0;i<n;i++)
  113.                                          {
  114.                                                 if(strcmp(student[i].id,find)==0)
  115.                                                 {
  116.                                                 count++;
  117.                                                 if (count==PF_FLOATING_POINT_EMULATED)
  118.                                                         printf("学生学号\t学生班级\t学生姓名\t上机时间\n");
  119.                                                 printf("%8s%15s%15s%17s",student[i].id,student[i].theclass,student[i].name,student[i].ontime);
  120.                                                 }
  121.                                          }
  122.                                          if(!count)
  123.                                                  printf("****提示:该学生不存在");
  124.                                          goto A;
  125.                                 default:printf("****提示:该学生不存在");

  126.                 }
  127.                 A:printf("\n\t**1.继续\n\t**0.返回主菜单");
  128.                   printf("\n\t 请输入您的选择:");
  129.                   scanf("%d",&c);
  130.         }
  131.         while(c);
  132. }
  133. void menu()
  134. {
  135.         printf("\n\t*******************欢迎进入机房收费管理系统!*******************\n");
  136.         printf("\t**1.录入功能**\n");
  137.         printf("\t**2.计算功能**\n");
  138.         printf("\t**3.查询功能**\n");
  139.         printf("\t**4.***EXIT***\n");
  140.         printf("\n\t请输入您的选择:");
  141. }
  142. void main()
  143. {
  144.         system("color 5f");
  145.         int a;
  146.         C:menu();
  147.           scanf("%d",&a);
  148.           switch(a)
  149.           {
  150.           case 4 :printf("***正在退出**谢谢使用本系统,再见");break;
  151.           case 1 :addition();
  152.                   goto C;
  153.           case 2 :calculate();
  154.                   goto C;
  155.           case 3 :search();
  156.                   goto C;
  157.           }
  158. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-11 20:08:09 | 显示全部楼层
TOP_LK 发表于 2019-6-10 16:00
你先打,我帮你改bug

这个我不知道为啥我录入学生的时候他只有学号和班级,没有了上机时间和姓名。还有就是我想插入一个中途退出选项,不知道要咋插入
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-6-11 21:01:35 | 显示全部楼层    本楼为最佳答案   
  1. printf("\n\t请输入第%d个学生学号:",i);
  2.                 scanf("%s",student[i-1].id);
  3.                 printf("\n\t请输入第%d个学生班级:",i);
  4.                 scanf("%s",student[i-1].theclass);
  5.                 printf("\n\t请输入第%d个学生学号:",i);
  6.                 scanf("%s",student[i-1].name);
  7.                 printf("\n\t请输入第%d个学生学号:",i);
  8.                 scanf("%s",student[i-1].ontime);
复制代码

因为你把时间和姓名写成了学号
中途退出功能你可以设置一个特殊按键,若输入为该按键时回到主界面。

点评

......好,谢谢大佬  发表于 2019-6-11 23:43
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-7 09:48

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表