| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2002 人关注过本帖
标题:新手求教,较简单的学生选课系统剩余两个问题不知道该怎么改
只看楼主 加入收藏
奔跑的汉子
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-2-23
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
新手求教,较简单的学生选课系统剩余两个问题不知道该怎么改
#include <stdio.h>
#include<stdlib.h>
struct course
{  
    int num;  
    char name[15];
    char xingzhi[10];
    int ttime;
    int score;
 };
struct student
{
    int snum;
    int cnum;
}
   
/*insert*/
voidinsert()
{   
    void menu();  
    FILE *fp;   
    struct course c;  
    if((fp=fopen("course.txt","a+"))==NULL)  
    {  
        printf("cannot open file\n");   
    }      
    printf("\n\tInput course's information :\n");   
    printf("\tthe format is num name xingzhi ttime score:\n");
    scanf("%d %s %s %d %d",&c.num,&c.name,&c.xingzhi,  &c.ttime,&c.score);
    fprintf(fp,"%d %s %s %d %d",c.num,c.name,c.xingzhi,  c.ttime,c.score);
    fclose(fp);
    menu();
}
   
/*browse liu_lan*/
void browser()
{  
    void menu();  
    FILE *fp;   
    struct course c;   
    if((fp=fopen("course.txt","r"))==NULL)  
    {  
        printf("\nCannot open course!\n");  
    }   
    for(;!feof(fp);)  
    {   
        fscanf(fp,"%d%s%s%d%d",&c.num,&c.name,&c.xingzhi,  &c.ttime,&c.score);
        printf("%d %s %s %d %d",c.num,c.name,c.xingzhi,  c.ttime,c.score);
    }   fclose(fp);
    menu();
 }
   
/*search*/
void search()
{   
    void menu();  
    FILE *fp;   
    struct course c;  
    int score;   
    printf("\ninput mark your wantto search:");  
    scanf("%d",&score);     
    if((fp=fopen("course.txt","r"))==NULL)  
    {   
        printf("\nCannot open course!\n");
    }   
    for(;!feof(fp);)  
    {   
        fscanf(fp,"%d %s %s %d %d",&c.num,&c.name,&c.xingzhi,&c.ttime,&c.score);   
        if(c.mark==score)   
            printf("%d %s %s %d %d",c.num,c.name,c.xingzhi,c.ttime,c.score);
    }   
    fclose(fp);
    menu();
}
  
/*tong ji xuan ke ren  shu*/
void xuanke_information()
{   
    void menu();
    int total=0;
    FILE *fp;   
    struct student c;
    int num;
    printf("\ninput course -number your wantto search:");  
    scanf("%d",&num);   
    if((fp=fopen("student.txt","r"))==NULL)  
    {   
        printf("\nCannot open student!\n");
    }   
    for(;!feof(fp);)
    {  
        fscanf(fp,"%d%d",&c.snum,&);
        if()
        {     
            total++;
            printf("student_num=%d,course_num=%d",c.snum,);
        }  
    }   
    fclose(fp);
    printf("\n The number choose course_num %d is %d!",num,total);  menu();
 }
   
/*xuanke*/
 void xuan_ke()
 {   
     void menu();
     int snum,cnum;
     FILE *fp;  
     printf("\nPlease input your student_number and course number you want to choose:");
     scanf("%d%d",&snum,&cnum);   
     if((fp=fopen("student.txt","a+"))==NULL)
     {
         printf("\nCannot open student!\n");
     }   
     fprintf(fp,"%d %d",snum,cnum);
     fclose(fp);
     menu();
 }  
 void menu()  
 {
     int n,w=0;
     printf("\n\t\t PLEASE ENTER A NUMBER FROM 0 TO 5!");
     printf("\n\n\n\t*******************MENU**************************");
     printf("\n\t\t 1 - insert informations");
     printf("\n\t\t 2 - browers informations");  
     printf("\n\t\t 3 - search informations");  
     printf("\n\t\t 4 - xuan ke  informations");
     printf("\n\t\t 5- xuan ke ");  
     printf("\n\t\t 0 - Exit system");  
     printf("\n\n\n\t********************************************");
     printf("\n\n\n\n\n\n\t\tChoose the number,please:");
     scanf("%d",&n);
     do
     {
         if(n>5||n<0)
         {  
             printf("\nWrong! input again!");
             scanf("%d",&n);
         }  
         else w=1;
     }
     while(w==0);
     switch(n)
     {
     case 1:insert();
         break;
     case 2:browser();
         break;
     case 3:search();
         break;
     case 4:xuan_ke();
         break;   
     case 5:xuanke_information();
         break;
     case 0:exit(0);
     }
 }
 main()
 {  
     menu();
}
搜索更多相关主题的帖子: cannot course include insert file 
2017-02-23 23:57
奔跑的汉子
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-2-23
收藏
得分:0 
折腾了一个晚上了原谅我没学好
2017-02-23 23:57
奔跑的汉子
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-2-23
收藏
得分:0 
从十几个问题改到现在剩两个实在不会了
2017-02-23 23:58
奔跑的汉子
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-2-23
收藏
得分:0 
求帮助,谢谢
2017-02-23 23:58
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
收藏
得分:20 
楼主大概是没有读英语编译信息的习惯吧。其实都直接提示出来了
#include <stdio.h>
#include<stdlib.h>
struct course
{  
    int num;  
    char name[15];
    char xingzhi[10];
    int ttime;
    int score;
 };
struct student
{
    int snum;
    int cnum;
}
   ;             //这里要有个分号
/*insert*/
void insert()      //void后面少了个空格
{   
    void menu();  
    FILE *fp;   
    struct course c;  
    if((fp=fopen("course.txt","a+"))==NULL)  
    {  
        printf("cannot open file\n");   
    }      
    printf("\n\tInput course's information :\n");   
    printf("\tthe format is num name xingzhi ttime score:\n");
    scanf("%d %s %s %d %d",&c.num,&c.name,&c.xingzhi,  &c.ttime,&c.score);
    fprintf(fp,"%d %s %s %d %d",c.num,c.name,c.xingzhi,  c.ttime,c.score);
    fclose(fp);
    menu();
}
   
/*browse liu_lan*/
void browser()
{  
    void menu();  
    FILE *fp;   
    struct course c;   
    if((fp=fopen("course.txt","r"))==NULL)  
    {  
        printf("\nCannot open course!\n");  
    }   
    for(;!feof(fp);)  
    {   
        fscanf(fp,"%d%s%s%d%d",&c.num,&c.name,&c.xingzhi,  &c.ttime,&c.score);
        printf("%d %s %s %d %d",c.num,c.name,c.xingzhi,  c.ttime,c.score);
    }   fclose(fp);
    menu();
 }
   
/*search*/
void search()
{   
    void menu();  
    FILE *fp;   
    struct course c;  
    int score;   
    printf("\ninput mark your wantto search:");  
    scanf("%d",&score);     
    if((fp=fopen("course.txt","r"))==NULL)  
    {   
        printf("\nCannot open course!\n");
    }   
    for(;!feof(fp);)  
    {   
        fscanf(fp,"%d %s %s %d %d",&c.num,&c.name,&c.xingzhi,&c.ttime,&c.score);   
        if(c.mark==score)                //没有mark这个成员,改成score
            printf("%d %s %s %d %d",c.num,c.name,c.xingzhi,c.ttime,c.score);
    }   
    fclose(fp);
    menu();
}
  
/*tong ji xuan ke ren  shu*/
void xuanke_information()
{   
    void menu();
    int total=0;
    FILE *fp;   
    struct student c;
    int num;
    printf("\ninput course -number your wantto search:");  
    scanf("%d",&num);   
    if((fp=fopen("student.txt","r"))==NULL)  
    {   
        printf("\nCannot open student!\n");
    }   
    for(;!feof(fp);)
    {  
        fscanf(fp,"%d%d",&c.snum,&);
        if()
        {     
            total++;
            printf("student_num=%d,course_num=%d",c.snum,);
        }  
    }   
    fclose(fp);
    printf("\n The number choose course_num %d is %d!",num,total);  menu();
 }
   
/*xuanke*/
 void xuan_ke()
 {   
     void menu();
     int snum,cnum;
     FILE *fp;  
     printf("\nPlease input your student_number and course number you want to choose:");
     scanf("%d%d",&snum,&cnum);   
     if((fp=fopen("student.txt","a+"))==NULL)
     {
         printf("\nCannot open student!\n");
     }   
     fprintf(fp,"%d %d",snum,cnum);
     fclose(fp);
     menu();
 }  
 void menu()  
 {
     int n,w=0;
     printf("\n\t\t PLEASE ENTER A NUMBER FROM 0 TO 5!");
     printf("\n\n\n\t*******************MENU**************************");
     printf("\n\t\t 1 - insert informations");
     printf("\n\t\t 2 - browers informations");  
     printf("\n\t\t 3 - search informations");  
     printf("\n\t\t 4 - xuan ke  informations");
     printf("\n\t\t 5- xuan ke ");  
     printf("\n\t\t 0 - Exit system");  
     printf("\n\n\n\t********************************************");
     printf("\n\n\n\n\n\n\t\tChoose the number,please:");
     scanf("%d",&n);
     do
     {
         if(n>5||n<0)
         {  
             printf("\nWrong! input again!");
             scanf("%d",&n);
         }  
         else w=1;
     }
     while(w==0);
     switch(n)
     {
     case 1:insert();
         break;
     case 2:browser();
         break;
     case 3:search();
         break;
     case 4:xuan_ke();
         break;   
     case 5:xuanke_information();
         break;
     case 0:exit(0);
     }
 }
 main()
 {  
     menu();
}
2017-02-26 10:10
快速回复:新手求教,较简单的学生选课系统剩余两个问题不知道该怎么改
数据加载中...
 
   



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

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