题目:
学生姓名,卡号.消费时间,金额,消费类型
要求:
1.添加某个学生的某次消费记录
2.删除某个学生的某次消费记录
3.显示某个学生的消费记录
4.查找某个时间段内消费的学生,并按照消费金额的多少进行排序
  我现在基本上已经把前边的弄好了 就差最后一个要求的了
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
static int number=0;
struct time{
    int month;
    int day;
};
struct student{
    char name[10];
    float xiaofei[10];
    char cnumber[20];
    struct time stime;
        char leixing[10];
        struct student* next;
};
struct student* addst(struct student* s_he)
{
    
    struct student* s_st=NULL;
    struct student* s_ne=NULL;    
    if(s_he!=NULL)
        for(s_ne=s_he;s_ne->next!=NULL;s_ne=s_ne->next);
        do{
        s_st=(struct student*)malloc(sizeof(struct student));
        printf("\nPlease putin name xiaofei cnumber time leixing:");
        scanf("%s %s %s %d %d %s",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day, s_st->leixing);
        if(number==0) s_he=s_st;
        else s_ne->next=s_st;
        s_ne=s_st;
        number++;
        printf("\nDo you continue?(y/n)\n");    
        }while(getch()=='y');
    s_ne->next=NULL;
    return s_he;
}
void savest(struct student* s_st)
{
    char str[30];
    FILE *f_1;
    int num=0;
    printf("\nFILE NAME:");
    scanf("%s",str);
    f_1=fopen(str,"w");
    for(;num<number;num++,s_st=s_st->next)
        fprintf(f_1,"ID:%d\tNAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tTIME:%d %d\tLEIXING:%s\n",num,s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
    fclose(f_1);
}
struct student* deletest(struct student* s_he)
{
    struct student* s_1=s_he;
    struct student* s_2=s_he;
    struct student* s_3=s_he;
    int i;
    int idnum=1;
    do{
        printf("\nID:");
        scanf("%d",&idnum);
    }while(idnum<0||idnum>=number);
    if(idnum==1){
        s_he=s_he->next;
        free(s_1);
    }
    else{
        for(i=0;i<idnum-1;i++)
            s_1=s_1->next;
        s_2=s_1->next;
        if(idnum==number-1){
            s_1->next=NULL;
            free(s_2);
        }
        else{
            s_3=s_2->next;
            s_1->next=s_3;
            free(s_2);
        }
    }
    number--;
    return s_he;
}
void displayst(struct student* s_st)
{
    char str[7];
    int i=0;
    printf("\nNAME:");
    scanf("%s",str);
    for(;s_st!=NULL;s_st=s_st->next,i++)
        if(strcmp(str,s_st->name)==0){
            printf("ID:%d\tNAME:%s\tXIAOFEI:%s\tCNUMBER:%s\StTIME:%d %d\tLEIXING:%s\n",i,s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
                         }
}
void changest(struct student* s_st)
{
    int idnum=1;
    int i=0;
    do{
        printf("\nID:");
        scanf("%d",&idnum);
    }while(idnum<0||idnum>=number);
    for(;i<idnum;i++,s_st=s_st->next);
    printf("NAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tSTIME:%d %d\tLEIXING:%s\n",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
    printf("\nPlease putin name xiaofei cnumber time leixing:");
    scanf("%s,%s,%s,%d %d,%s",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
    printf("NAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tSTIME:%d %d\tleixing:%s\n",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
}
void paixust(struct student* s_st)
{
    struct time str,endt;
    int  i=0;
    printf("\n the start time:");
    scanf("%d %d",&str.month,&str.day);
    printf("\n the end time :");
    scanf("%d %d",&endt.month,&endt.day);
    for(;s_st!=NULL;s_st=s_st->next,i++)
       if (str.month*31+str.day<= s_st->stime.month*31+s_st->stime.day &&s_st->stime.month*31+s_st->stime.day <=endt.month*31+endt.day){
            printf("ID:%d\tNAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tSTIME:%d %d\tLEIXING:%s\n",i,s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
}
}
main()
{
    struct student* s_he=NULL;
    do{
        printf("**************************************************\n");
        printf("%dperson joined\n",number);
        printf("1.add\n2.detele\n3.display\n4.change\n5.save\n6.paixu\n7.exit\n");
        printf("**************************************************\n");
                switch (getch()){
        case '1':
            s_he=addst(s_he);
            break;
        case '2':
            if(number>0)
                s_he=deletest(s_he);
            break;
        case '3':
            if(number>0)
                displayst(s_he);
            break;
        case '4':
            if(number>0)
                changest(s_he);
            break;
        case '5':
            if(number>0)
                savest(s_he);
            break;
        case'6':
                       if(number>0)
                       paixust(s_he);
                       break;
                case '7':
            exit(0);
        }
    }while(1);
}