网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
12月01日漏签0天
c语言吧 关注:801,364贴子:4,372,631
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 8回复贴,共1页
<<返回c语言吧
>0< 加载中...

谁能解决这个问题?

  • 只看楼主
  • 收藏

  • 回复
  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
编的程序,但是老有问题,修改跟删除老是有毛病!!!
不晓得 有什么比较厉害的人能解决一下呢
小女子 不胜感激啊!!!


  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
                      
                    }
                   i++;
                   fread(&stu[i],sizeof(STUDENT),1,fp);
                }
                    if(flag==0)
                        printf("该姓名不存在!!\n");
                
                 break;
           case 3:return;
           default:
                 printf("请选择编号\n");  
             }
     }
     fclose(fp);
    
     fp=fopen("c:\\score.dat","wb");
     if(fp==NULL)
     {
         printf("Open error!!");
         getch();
         exit(0);
     }
     for(i=0;i<N;i++){
         fwrite(&stu[i],sizeof(STUDENT),1,fp);
     }
     fclose(fp);
}
void stu_del()      /*删除学生信息函数*/
{
     STUDENT s[N];
     int i,j,number,flag,n=0;
     char name1[8],num1[12];
     FILE *fp=NULL;
     title("删除学生信息\n");
     gotoxy(28,5);
     printf("**********************\n");
     gotoxy(28,6);
     printf("*****1.按学号删除*****\n");
     gotoxy(28,7);
     printf("*****2.按姓名删除*****\n");
     gotoxy(28,8);
     printf("*****3.退出本菜单*****\n");
     gotoxy(28,9);
     printf("**********************\n");
    
     fp=fopen("c:\\score.dat","rb");



2025-12-01 00:10:36
广告
不感兴趣
开通SVIP免广告
  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
                           }
                         n++;
                      }
                        if(flag==0){
                               printf("该学号不存在!\n");
                            }
                 break;
          case 2:
                 printf("输入要删除的学生姓名:");
                 scanf("%s",name1);
                 for(i=0;i<N;i++)
                     if(strcmp(s[i].name,name1)==0)
                       {   
                           flag=1;
                           for(j=i;j<N-1;j++){
                                 strcpy(s[j].number,s[j+1].number);
                              strcpy(s[j].name,s[j+1].name);
                                 strcpy(s[j].sex,s[j+1].sex);
                                 s[j].mid=s[j+1].mid;
                                 s[j].end=s[j+1].end;



  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
         exit(0);
     }
     for(i=0;i<N;i++){
        fread(&stu[i],sizeof(STUDENT),1,fp);;
     }
     while(1)
     {   
         printf("\n请选择子菜单编号:");
         scanf("%d",&number);
         flag=0;
         switch(number)
               {
               case 1:
                       printf("请输入要查询的学生的学号:");
                       scanf("%s",s1);
                       for(i=0;i<N;i++)
                          if(strcmp(stu[i].number,s1)==0)
                            {   
                                   flag=1;
                                stu[i].total=stu[i].mid*0.3+stu[i].end*.3+stu[i].peacetime*0.4;
                                printf("学号\t姓名\t性别\t期中\t期末\t平时\n");
                                printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\n",stu[i].number,stu[i].name,stu[i].sex,stu[i].mid,stu[i].end,stu[i].peacetime);
                                printf("学期总评:%.2lf\t",stu[i].total);
                                if(stu[i].total>=85&&stu[i].total<=100)



  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
                                           printf("优秀");
                                else if(stu[i].total>=75&&stu[i].total<85)
                                        printf("良好");
                                else if(stu[i].total>=60&&stu[i].total<75)
                                        printf("及格");
                                else if(stu[i].total>=0&&stu[i].total<60)
                                        printf("不及格");
                                printf("\n");
                            }
                          if(flag==0)
                                printf("该学号不存在!\n");     
                        break;
             case 2:
                     printf("请输入要查询的学生的姓名:");
                     scanf("%s",s1);



  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
                     for(i=0;i<N;i++)
                        if(strcmp(stu[i].name,s1)==0)
                          {   
                               flag=1;
                              stu[i].total=stu[i].mid*0.3+stu[i].end*.3+stu[i].peacetime*0.4;
                              printf("学号\t姓名\t性别\t期中\t期末\t平时\n");
                              printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\n",stu[i].number,stu[i].name,stu[i].sex,stu[i].mid,stu[i].end,stu[i].peacetime);
                              printf("学期总评:%.2lf\t",stu[i].total);
                              if(stu[i].total>=85&&stu[i].total<=100)
                                     printf("优秀");
                              else if(stu[i].total>=75&&stu[i].total<85)
                                  printf("良好");
                              else if(stu[i].total>=60&&stu[i].total<75)
                                  printf("及格");
                              else if(stu[i].total>=0&&stu[i].total<60)



  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
                                  printf("不及格");
                              printf("\n");
                          }
                        if(flag==0)
                              printf("该姓名不存在!\n");     
                     break;
            case 3:   return;
            default:
                    printf("请在选择编号\n");
            }
     }
     fclose(fp);
}
void stu_all()        /*显示全部联系人*/
{
     
      int number;
      STUDENT stu;
      FILE *fp=NULL;    
      title("显示学生信息\n");
      gotoxy(26,6);
      printf("************************\n");
      gotoxy(26,7);
      printf("*******1.显示信息*******\n");
      gotoxy(26,8);
      printf("*******2.退出显示*******\n");
      gotoxy(26,9);
      printf("************************\n");
      fp=fopen("c:\\score.dat","rb");
      if(fp==NULL)
      {
           printf("Open error!!!");
           getch();
           exit(0);
      }
      while(1)
      {   
         printf("\n请选择子菜单编号:");
         scanf("%d",&number);
         switch(number){



  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
         case 1:
                
                 printf("学生信息为:\n");
                 fread(&stu,sizeof(STUDENT),1,fp);
                 while(feof(fp)==0){
                        stu.total=stu.mid*0.3+stu.end*.3+stu.peacetime*0.4;
                        printf("学号\t姓名\t性别\t期中\t期末\t平时\n");
                       printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\n",stu.number,stu.name,stu.sex,stu.mid,stu.end,stu.peacetime);
                       printf("学期总评:%.2lf\t",stu.total);
                       if(stu.total>=85&&stu.total<=100)
                              printf("优秀");
                       else if(stu.total>=75&&stu.total<85)
                           printf("良好");
                       else if(stu.total>=60&&stu.total<75)
                           printf("及格");
                       else if(stu.total>=0&&stu.total<60)
                           printf("不及格");
                       printf("\n");
                       fread(&stu,sizeof(STUDENT),1,fp);



2025-12-01 00:04:36
广告
不感兴趣
开通SVIP免广告
  • t缘字诀
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
                 }
                 break;
          case 2:return;
          default:
                  printf("请选择编号\n");
         }
        
       }
      fclose(fp);
}
void main()
{
     gotoxy(27,6);
     printf("请用数字键选择操作\n\n");
     gotoxy(28,8);
     printf("1 添加学生信息\n");
     gotoxy(28,10);
     printf("2 修改学生成绩\n");
     gotoxy(28,12);
     printf("3 删除学生信息\n");
     gotoxy(28,14);
     printf("4 查看学生信息\n");
     gotoxy(28,16);
     printf("5 显示学生信息\n\n");
     gotoxy(28,18);
     printf("0 退出\n");
     switch(getch())
           {
               case '1' : stu_add();break;      /*添加学生信息*/
               case '2' : stu_change();break;   /*修改学生信息*/
              case '3' : stu_del();break;      /*删除学生信息*/
               case '4' : stu_read();break;     /*查询学生信息*/
               case '5' : stu_all();break;      /*全部学生信息*/
               case '0' : exit(0);              /*退出*/
           }
}



登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 8回复贴,共1页
<<返回c语言吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示