那些年我写过的代码 | 开源中国10周年

LeoXu 发布于 2018/08/08 01:55
阅读 288
收藏 0

08年我还在读大二,同学对我的印象比较接近书呆子那一类,而那时的我自认为存在感比较弱,所以说故事嘛,除了患点单相思之外,并没有什么好博诸位一哂的。

那些年单相思过的女孩,现早已经结婚生子,过上了幸福的生活,遗憾的是收获她放心的人不是我,不提也罢。

这一年,我用 C 语言完成的大二的中期实习作业,现在看看,想来似乎那时就已经注定了我要在孤独终老的路上一条道走向黑,除了能在寝室里一个人跟电脑玩的红色警戒,能留下纪念的,也就这就这几行代码了:

/* 标准文档模板 */

#include "Stdio.h"
#include "Conio.h"
#include "String.h"

#define Header1 "-------------------------SCORE-------------------------\n"
#define Header2 "|Number  |Name    |Sex|Age |Math    |Chinese |English |\n"
#define FORMAT  "|%-8s|%-8s|%-3c|%-4d|%-8d|%-8d|%-8d|\n"
#define DATA p->num,p->name,p->sex,p->age,p->score[0],p->score[1],p->score[2]

/*int  saveflag=0;*/

typedef struct student
{
    char num[20];
    char name[20];
    char sex;  /*1代表男,2代表女*/
    int age;
    int score[3];
    int sum;
    float avg;
    struct student *next;
}Stu;

/*保存修改*/
Stu *sl_save(Stu *head,Stu *head2,char sl[20])
{
    Stu *p,*q;
    FILE *fp;
    fp=fopen(sl,"wb");
    if(fp==NULL)
    {
        printf("\nfile save error!");
        return;
    }
    p=head->next;
    while(p!=NULL)
    {
        q=p;
        p=p->next;
    }
    /*链结新旧链表*/
    q->next=head2->next;
    p=head->next;
    while(p)
    {
        fwrite(p,sizeof(Stu),1,fp);
        p=p->next;
    }
    fclose(fp);
    return head;
}

/*新建学生成绩数据表*/
void new_sl()
{
    FILE *fp;
    Stu s;
    float x;
    int i,sum=0,avg;
    char bname[20];
    char c;
    printf("input the new score list name:");
    /*输入字符串为则空循环*/
    do
    {
        scanf("%s",bname);
    }
    while(!(sizeof(bname)-1));
    if((fp=fopen(bname,"wb"))==NULL)
    {
        printf("score list init error.\n");
        exit(0);
    }
    do
    {
        printf("input the student number(input '-1' to exit):");
        do
        {
            scanf("%s",&s.num);
        }
        while(!(sizeof(s.num)-1));
        getchar();
        if(strcmp(s.num,"-1")!=0)
        {
            printf("input student's name:");
            do
            {
                scanf("%s",&s.name);
            }
            while(!(sizeof(s.name)-1));
            getchar();
            printf("input the student's sex:(m\\f)\n");
            do
            {
                scanf("%c",&c);
            }
            while((c!='f')&&(c!='m'));
            s.sex=c;
            printf("input the student's age(10~20):");
            do
            {
                scanf("%d",&s.age);
            }
            while(!(s.age>=10&&s.age<=20));
            printf("input the score of Yuwen,Yingyu and Shuxue(0~100):");
            for(i=0;i<3;i++)
            {
                do
                {
                    scanf("%d",&s.score[i]);
                    sum+=s.score[i];
                }
                while(!(s.score[i]>=0&&s.score[i]<=100));
            }
            s.sum=sum;
            s.avg=(float)(sum/3);
            s.next=NULL;
            fwrite(&s,sizeof(Stu),1,fp);
        }
        else break;
    }
    while(1);
    fclose(fp);
}

/* 判定是否创建新的学生成绩数据表的函数*/
void sl_create()
{
    char ch;
    textcolor(2);
    printf("Do you want to create new score list?\n");
    printf("Press 'y' to create or press any key to ship:");
    ch=getchar();
    getchar();
    if(ch=='y'||ch=='Y') new_sl();
}

/*打开并读取一个学生成绩文件函数*/
Stu * sl_read(char slname[20])
{
    FILE *sfp;
    Stu *s_head;
    Stu *s_last;
    Stu *p;
    /*打开文件*/
    s_head=(Stu *)malloc(sizeof(Stu));
    s_head->next=NULL;
    s_last=s_head;
    sfp=fopen(slname,"rb");
    if(sfp==NULL)
    {
        return NULL;
    }
    /*从文件中读取学生成绩表,放入链表中存放*/
    while(!feof(sfp))
    {
        p=(Stu *)malloc(sizeof(Stu));
        if(fread(p,sizeof(Stu),1,sfp)==1)
        {
            p->next=NULL;
            s_last->next=p;
            s_last=p;
        }
    }
    fclose(sfp);
    /*返回读出的成绩表文件头指针*/
    return s_head;
    exit(0);
}

/*浏览学生成绩*/
void sl_dsp(Stu *head)
{
    Stu *p;
    clrscr();
    if(head==NULL)
    {
        printf("The list is empty.\n");
        return;
    }
    p=head->next;
    if(!p)
    {
        printf("\nNo score record!\n");
        getchar();
    }
    printf("\n\n");
    printf(Header1);
    printf(Header2);
    while(p)
    {
        printf(FORMAT,DATA);
        p=p->next;
    }
    printf("Press any key to return to continue:");
    getchar();
    return;
}

void sl_dsp1(Stu *head)
{
    int select5;
    int i=0,max,min,m1=0,m2=0,m3=0,mi1=0,mi2=0,mi3=0,s1,s2,s3,a1,a2,a3;
    Stu *p;
    scanf("%d",&select5);
    switch(select5)
    {
        case 0:break;
        case 1:
            p=head->next;
            printf("~~~~~~~~~~~~~~~~~~~REPORT BY STUDENT!~~~~~~~~~~~~~~~~~~\n");
            printf("|NUM     |NAME    |SUM     |AVG     |MAX     |MIN     |\n");
            while(p)
            {
                max=p->score[0];
                min=p->score[0];
                if(p->score[0]<p->score[1]) max=p->score[1];
                if(p->score[1]<p->score[2]) max=p->score[2];
                if(p->score[0]>p->score[1]) min=p->score[1];
                if(p->score[1]>p->score[2]) min=p->score[2];
                printf("|%-8s|%-8s|%-8d|%-8.0f|%-8d|%-8d|\n",p->num,p->name,p->sum,p->avg,max,min);
                p=p->next;
            }
            printf("Press any key to continue:");
            getchar();
            break;
        case 2:
            p=head->next;
            printf("~~~~~~~~~~~~~REPORT BY STUDENT!~~~~~~~~~~~~~~~\n");
            printf("|Courses |Sum     |Avg     |Max     |Min     |\n");
            p=head->next;
            while(p)
            {
                s1=s1+p->score[0];
                s2=s2+p->score[1];
                s3=s3+p->score[2];
                if(m1<p->score[0])m1=p->score[0];
                if(mi1>p->score[0])mi1=p->score[0];
                if(m2<p->score[1])m2=p->score[1];
                if(mi2>p->score[1])mi2=p->score[1];
                if(m3<p->score[2])m3=p->score[2];
                if(mi3>p->score[2])mi3=p->score[2];
                i=i+1;
                p=p->next;
            }
            a1=(float)(s1/i);
            a2=(float)(s2/i);
            a3=(float)(s3/i);
            printf("|Math    |%-8d|%-8.0f|%-8d|%-8d|\n",s1,a1,m1,mi1);
            printf("|Chinese |%-8d|%-8.0f|%-8d|%-8d|\n",s2,a2,m2,mi2);
            printf("|English |%-8d|%-8.0f|%-8d|%-8d|\n",s3,a3,m3,mi3);
            printf("Press any key to continue:");
            getchar();
            break;
        default:
            break;
    }
    getch();
}

void sl_dsp2(Stu *head)
{
    Stu *p;
    clrscr();
    if(head==NULL)
    {
        printf("The list is empty.\n");
        return;
    }
    p=head->next;
    if(!p)
    {
        printf("\nNo score record!\n");
        getchar();
    }
    printf("\n\n");
    printf(Header1);
    printf(Header2);
    while(p)
    {
        printf(FORMAT,DATA);
        p=p->next;
        break;
    }
    printf("Press any key to return to continue:");
    getchar();
    return;
}

/*查看学校是否已经存在函数*/
int sl_check(Stu *head,char num[20])
{
    Stu *p;
    p=head->next;
    while(p)
    {
        if(strcmp(p->num,num)==0) return 1;
        p=p->next;
    }
    return 0;
}

/*添加学生信息函数*/
Stu *sl_add(Stu *head,char sl[20])
{   
    Stu *p,*r,*head2;
    int sum=0,avg,i,j=1;
    char c;
    clrscr();
    head2->next=NULL;
    r=head2;
    while(r->next!=NULL)
    {
        r=r->next;
    }
    while(j)
    {
        printf("input student's number(input '-1'to back main menu):");
        p=(Stu *)malloc(sizeof(Stu));
        do
        {
            scanf("%s",&p->num);
        }
        while(!(sizeof(p->num)-1));
        /*查看学号是否已经存在循环*/
        while(sl_check(head,p->num))
        {
            printf("the students has existed,input again:\n");
            do
            {
                scanf("%s",&p->num);
            }
            while(!(sizeof(p->num)-1));
        }
        if(strcmp(p->num,"-1")==0)
        {
            printf("Press any key to exit:\n");
            getchar();
            j=0;
        }
        else
        {
            printf("input student's name:");
            do
            {
                scanf("%s",&p->name);
            }
            while(!(sizeof(p->name)-1));
            getchar();
            printf("input the student's sex:(m\\f)\n");
            do
            {
                scanf("%c",&c);
            }
            while((c!='f')&&(c!='m'));
            p->sex=c;
            printf("input the student's age(10~20):");
            do
            {
                scanf("%d",&p->age);
            }
            while(!(p->age>=10&&p->age<=20));
            printf("input the score of Yuwen,Yingyu and Shuxue(0~100):");
            for(i=0;i<3;i++)
            {
                do
                {
                    scanf("%d",&p->score[i]);
                    sum+=p->score[i];
                }
                while(!(p->score[i]>=0&&p->score[i]<=100));
            }
            p->sum=sum;
            p->avg=(float)(sum/3);
            p->next=NULL;
            r->next=p;
            r=p;
        }
    }
    sl_dsp(head2);
    printf("Save or not(y\\n)?\n");
    do
    {
        scanf("%c",&c);
    }
    while((c!='y')&&(c!='n'));
    getchar();
    if(c=='y')
    {
        head=sl_save(head,head2,sl);
        printf("Save success,Press any key to continue:");
        getchar();
        return head;
    }
    else
    {
        printf("Adding process over,Press any key to continue:");
        getchar();
        return head;
    }
}

/*删除成绩记录相关函数*/
/*保存删除结果*/
Stu *sl_savedel(Stu *head,char sl[20])
{
    Stu *p;
    FILE *fp;
    fp=fopen(sl,"wb");
    if(fp==NULL)
    {
        printf("\nfile save error!");
        return;
    }
    while(p)
    {
        fwrite(p,sizeof(Stu),1,fp);
        p=p->next;
    }
    fclose(fp);
    return head;
}

/*按姓名删除*/
Stu *sl_delbynam(Stu *head)
{
    Stu *p,*r;
    char sname[20];
    clrscr();
    sl_dsp(head);
    if(!head->next)
    {
        printf("\nNO student record!\n");
        return head;
    }
    printf("Input student's name:\n");
    do
    {
        scanf("%s",sname);
    }
    while(!(sizeof(sname)-1));
    p=head->next;
    while(p&&strcmp(p->name,sname)!=0)
    {
        r=p;
        p=p->next;
    }
    if(strcmp(p->name,sname)==0)
    {
        r->next=p->next;
        free(p);
        printf("Delete success.\n");
        sl_dsp(head);
    }
    else printf("No fine.\n");
    getchar();
    return head;
}

/*按学号删除*/
Stu *s1_delbynum(Stu *head)
{
    Stu *p,*r;
    char snum[20];
    clrscr();
    sl_dsp(head);
    if(!head->next)
    {
        printf("\nNO student record!\n");
        return head;
    }
    printf("Input student's name:\n");
    do
    {
        scanf("%s",snum);
    }
    while(!(sizeof(snum)-1));
    p=head->next;
    while(p&&strcmp(p->num,snum)!=0)
    {
        r=p;
        p=p->next;
    }
    if(strcmp(p->num,snum)==0)
    {
        r->next=p->next;
        free(p);
        printf("Delete success.\n");
        sl_dsp(head);
    }
    else printf("No fine.\n");
    getchar();
    return head;
}

/*删除进程主函数*/
Stu *sl_delete(Stu *head,char sl[20])
{
    int select2;
    Stu *p;
    char c;
    p=head;
    scanf("%d",&select2);
    switch(select2)
    {
        case 1:
            head=sl_delbynam(head);
            getchar();
            break;
        case 2:
            head=s1_delbynum(head);
            break;
        case 0:
            break;
        default:
            break;
    }
        printf("Save or not(y\\n)?\n");
    do
    {
        scanf("%c",&c);
    }
    while((c!='y')&&(c!='n'));
    getchar();
    if(c=='y')
    {
        head=sl_savedel(head,sl);
        printf("Save success,Press any key to continue:");
        getchar();
        return head;
    }
    else
    {
        printf("Delete process over,Press any key to continue:");
        getchar();
        return p;
    }
}

/*查找学生成绩记录函数*/
void sl_search(Stu *head)
{
    Stu *p,*head2;
    char c;
    int select3,sum,i;
    char s[20];
    head2->next=NULL;
    p=head;
    printf("\nIput your select(Press keys except '1'and '2'to exit) :");
    scanf("%d",&select3);
    switch(select3)
    {
        case 1:
            printf("Input the student's name:");
            do
            {
                scanf("%s",s);
            }
            while(!(sizeof(s)-1));
            while(p)
            {
                if(strcmp(p->name,s)==0)
                {
                    head2->next=p;
                    sl_dsp2(head2);
                    break;
                }
                else p=p->next;
            }
            break;
        case 2:
            printf("Input the student's number:");
            do
            {
                scanf("%s",s);
            }
            while(!(sizeof(s)-1));
            while(p)
            {
                if(strcmp(p->num,s)==0)
                {
                    head2->next=p;
                    sl_dsp2(head2);
                    break;
                }
                else p=p->next;
            }
            break;
        case 0:
            break;
        default:
            break;
    }
    printf("Search process over,press any key to continue:");
    getchar();
}

/*修改学生成绩记录函数*/
Stu *sl_alt(Stu *head,char sl[20])
{
    int select4,sum,i;
    char c;
    char s[20];
    Stu *p,*q,*r;
    scanf("%d",&select4);
    switch(select4)
    {
        case 1:
            r=head;
            p=head->next;
            q=(Stu *)malloc(sizeof(Stu));
            clrscr();
            printf("Input the student's name(input '-1' to exit):");
            do
            {
                scanf("%s",q->name);
            }
            while(!(sizeof(q->name)-1));
            if(strcmp(q->name,"-1")==0)return head;
            while(p)
            {
                if(strcmp(p->name,q->name)==0)
                {   
                    printf("\nInput student's num:");
                    do
                    {
                        scanf("%s",&q->num);
                    }
                    while(!(sizeof(q->num)-1));
                    /*查看学号是否已经存在循环*/
                    while(sl_check(head,q->num))
                    {
                        printf("the students has existed,input again:\n");
                        do
                        {
                            scanf("%s",&q->num);
                        }
                        while(!(sizeof(q->num)-1));
                    }
                    printf("input the student's sex:(m\\f)\n");
                    do
                    {
                        scanf("%c",&c);
                    }
                    while((c!='f')&&(c!='m'));
                    q->sex=c;
                    printf("input the student's age(10~20):");
                    do
                    {
                        scanf("%d",&q->age);
                    }
                    while(!(q->age>=10&&q->age<=20));
                    printf("input the score of Yuwen,Yingyu and Shuxue(0~100):");
                    for(i=0;i<3;i++)
                    {
                        do
                        {
                            scanf("%d",&q->score[i]);
                            sum+=q->score[i];
                        }
                        while(!(q->score[i]>=0&&q->score[i]<=100));
                    }
                    q->sum=sum;
                    q->avg=(float)(sum/3);
                    q->next=NULL;
                    printf("Save or not(y\\n)?\n");
                    do
                    {
                        scanf("%c",&c);
                    }
                    while((c!='y')&&(c!='n'));
                    if(c=='y')
                    {
                        p=head->next;
                        while(p)
                        {
                            if(strcmp(p->name,q->name)==0)
                            {
                                r->next=q;
                                q->next=p;
                                free(p);
                                break;
                            }
                            else
                            {
                                r=p;
                                p=p->next;
                            }
                        }
                        head=sl_savedel(head,sl);
                        printf("Save success,Press any key to continue:");
                        getchar();
                        return head;
                    }
                    else
                    {
                        printf("Alting process over,Press any key to continue:");
                        getchar();
                        return head;
                    }
                    printf("hahah");
                    getchar();
                    getchar();
                }
                else
                {
                    r=p;
                    p=p->next;
                }
            }
            break;
        case 2:
            r=head;
            p=head->next;
            q=(Stu *)malloc(sizeof(Stu));
            clrscr();
            printf("Input the student's num(input '-1' to exit):");
            do
            {
                scanf("%s",q->num);
            }
            while(!(sizeof(q->num)-1));
            if(strcmp(q->num,"-1")==0)return head;
            while(p)
            {
                if(strcmp(p->num,q->num)==0)
                {   
                    printf("\nInput student's name:");
                    do
                    {
                        scanf("%s",&q->name);
                    }
                    while(!(sizeof(q->name)-1));
                    /*查看学号是否已经存在循环*/
                    do
                    {
                        scanf("%c",&c);
                    }
                    while((c!='f')&&(c!='m'));
                    q->sex=c;
                    printf("input the student's age(10~20):");
                    do
                    {
                        scanf("%d",&q->age);
                    }
                    while(!(q->age>=10&&q->age<=20));
                    printf("input the score of Yuwen,Yingyu and Shuxue(0~100):");
                    for(i=0;i<3;i++)
                    {
                        do
                        {
                            scanf("%d",&q->score[i]);
                            sum+=q->score[i];
                        }
                        while(!(q->score[i]>=0&&q->score[i]<=100));
                    }
                    q->sum=sum;
                    q->avg=(float)(sum/3);
                    q->next=NULL;
                    printf("Save or not(y\\n)?\n");
                    do
                    {
                        scanf("%c",&c);
                    }
                    while((c!='y')&&(c!='n'));
                    if(c=='y')
                    {
                        p=head->next;
                        while(p)
                        {
                            if(strcmp(p->name,q->name)==0)
                            {
                                r->next=q;
                                q->next=p;
                                free(p);
                                break;
                            }
                            else
                            {
                                r=p;
                                p=p->next;
                            }
                        }
                        head=sl_savedel(head,sl);
                        printf("Save success,Press any key to continue:");
                        getchar();
                        return head;
                    }
                    else
                    {
                        printf("Alting process over,Press any key to continue:");
                        getchar();
                        return head;
                    }
                    printf("hahah");
                    getchar();
                    getchar();
                }
                else
                {
                    r=p;
                    p=p->next;
                }
            }
            break;
        case 0:
            break;
        default:break;
    }
}
/*排序汇总函数*/
void sl_sort(Stu *head)
{
    int select6;
    Stu *p,*q,*r;
    if(head->next==NULL)
    {
        printf("No Record.Press Any Key To Continue:");
        getch();
        return;
    }
    r=head;
    p=head->next;
    scanf("%d",&select6);
    switch(select6)
    {
        case 0:
            break;
        case 1:
            if(p->next=NULL)
            {
                clrscr();
                sl_dsp(head);
                printf("Press any key to continue:");
                getch();
                return;
            }
            q=p->next;
            while(q)
            {
                if(p->score[0]<q->score[0])
                {
                    r->next=p->next;
                    p->next=q->next;
                    q->next=p;
                    r=head;
                    p=head->next;
                    q=p->next;
                }
                else
                {
                    r=p;
                    p=p->next;
                    q=p->next;
                }
            }
            clrscr();
            sl_dsp(head);
            printf("Press any key to continue:");
            break;
        case 2:
            if(p->next=NULL)
            {
                clrscr();
                sl_dsp(head);
                printf("Press any key to continue:");
                getch();
                return;
            }
            q=p->next;
            while(q)
            {
                if(p->score[1]<q->score[1])
                {
                    r->next=p->next;
                    p->next=q->next;
                    q->next=p;
                    r=head;
                    p=head->next;
                    q=p->next;
                }
                else
                {
                    r=p;
                    p=p->next;
                    q=p->next;
                }
            }
            clrscr();
            sl_dsp(head);
            printf("Press any key to continue:");
            break;
        case 3:
            if(p->next=NULL)
            {
                clrscr();
                sl_dsp(head);
                printf("Press any key to continue:");
                getch();
                return;
            }
            q=p->next;
            while(q)
            {
                if(p->score[2]<q->score[2])
                {
                    r->next=p->next;
                    p->next=q->next;
                    q->next=p;
                    r=head;
                    p=head->next;
                    q=p->next;
                }
                else
                {
                    r=p;
                    p=p->next;
                    q=p->next;
                }
            }
            clrscr();
            sl_dsp(head);
            printf("Press any key to continue:");
            break;
        default:
            break;
    }
    getch();
}

/*主界面函数*/
void menu(char s[20])
{
    system("cls");
    textcolor(2);
    gotoxy(10,5);
    cprintf("      The Student Score Management System--%-s\n",s);
    gotoxy(10,8);
    cprintf("************************MAIN MENU*********************\n");
    gotoxy(10,9);
    cprintf("** 1 Scan                 2 Add           3 Delete  **\n");
    gotoxy(10,10);
    cprintf("** 4 Search               5 Alt           6 Report  **\n");
    gotoxy(10,11);
    cprintf("** 7 Sort                                 0 Exit    **\n");
    gotoxy(10,12);
    cprintf("******************************************************\n");
}

/*删除界面函数*/
void menu_delete(char s[20])
{
    system("cls");
    textcolor(2);
    gotoxy(10,5);
    cprintf("      The Student Score Management System--%-s\n",s);
    gotoxy(10,8);
    cprintf("***********************DELETE MENU********************\n");
    gotoxy(10,9);
    cprintf("** 1 Delete By Student Name                         **\n");
    gotoxy(10,10);
    cprintf("** 2 Delete By Student Number                       **\n");
    gotoxy(10,11);
    cprintf("**                                        0 Exit    **\n");
    gotoxy(10,12);
    cprintf("******************************************************\n");    
}

/*查找学生界面函数*/
void menu_search(char s[20])
{
    system("cls");
    textcolor(2);
    gotoxy(10,5);
    cprintf("      The Student Score Management System--%-s\n",s);
    gotoxy(10,8);
    cprintf("***********************SEARCH MENU********************\n");
    gotoxy(10,9);
    cprintf("** 1 Search By Student Name                         **\n");
    gotoxy(10,10);
    cprintf("** 2 Search By Student Number                       **\n");
    gotoxy(10,11);
    cprintf("**                                        0 Exit    **\n");
    gotoxy(10,12);
    cprintf("******************************************************\n");      
}

/*修改学生界面函数*/
void menu_alt(char s[30])
{
    system("cls");
    textcolor(2);
    gotoxy(10,5);
    cprintf("      The Student Score Management System--%-s\n",s);
    gotoxy(10,8);
    cprintf("************************ALT MENU**********************\n");
    gotoxy(10,9);
    cprintf("** 1 Alt By Student Name                            **\n");
    gotoxy(10,10);
    cprintf("** 2 Alt By Student Number                          **\n");
    gotoxy(10,11);
    cprintf("**                                        0 Exit    **\n");
    gotoxy(10,12);
    cprintf("******************************************************\n");      
}

/*成绩汇总*/
void menu_report(char s[30])
{
    system("cls");
    textcolor(2);
    gotoxy(10,5);
    cprintf("      The Student Score Management System--%-s\n",s);
    gotoxy(10,8);
    cprintf("***********************REPORT MENU********************\n");
    gotoxy(10,9);
    cprintf("** 1 Report By Student                              **\n");
    gotoxy(10,10);
    cprintf("** 2 Report By Course                               **\n");
    gotoxy(10,11);
    cprintf("**                                        0 Exit    **\n");
    gotoxy(10,12);
    cprintf("******************************************************\n");    
}

/*排序汇总界面函数*/
void menu_sort(char s[30])
{
    system("cls");
    textcolor(2);
    gotoxy(10,5);
    cprintf("      The Student Score Management System--%-s\n",s);
    gotoxy(10,8);
    cprintf("************************SORT MENU*********************\n");
    gotoxy(10,9);
    cprintf("** 1 Sort By Chinese                                **\n");
    gotoxy(10,10);
    cprintf("** 2 Sort By Mathematics                            **\n");
    gotoxy(10,11);
    cprintf("** 3 Sort By English                      0 Exit    **\n");
    gotoxy(10,12);
    cprintf("******************************************************\n");
}

void main()
{
    Stu *sl_head;
    FILE *fp;
    char sl[20];
    int select1;
    /* 是否创建新的学生成绩数据表*/
    sl_create();
    /*打开读取学生成绩数据文件*/
    clrscr();
    printf("Choose a student score list to open and read.\n");
    printf("Input the student list file name(input '-1' to exit):");
    do
    {
        do
        {
            scanf("%s",sl);
            if(strcmp(sl,"-1")==0) exit(0);
        }
        while(!(sizeof(sl)-1));
        sl_head=sl_read(sl);
    }
    while(sl_head==NULL);
        clrscr();
    /*主界面*/
    do
    {
        menu(sl);
        scanf("%d",&select1);
        switch(select1)
        {
            case 0:
                exit(0);
                break;
            case 1:
                sl_dsp(sl_head);/*浏览学生成绩记录*/
                getch();
                break;
            case 2:
                sl_head=sl_add(sl_head,sl);/*添加学生成绩记录*/
                break;
            case 3:
                menu_delete(sl);
                sl_head=sl_delete(sl_head,sl);/*删除学生成绩记录*/
                break;
            case 4:
                menu_search(sl);
                sl_search(sl_head);
                break;
            case 5:
                menu_alt(sl);
                sl_head=sl_alt(sl_head,sl);
                break;
            case 6:
                menu_report(sl);
                sl_dsp1(sl_head);
                break;
            case 7:
                menu_sort(sl);
                sl_sort(sl_head);
                break;
            default:
                break;
        }
    }
    while(1);
    printf("GO ON!!!\n");
    getch();
}

另附上《单相思》一首,聊陈当年的忧桑:

冥冥中有道无形的边界
隔绝了你我目光的对接
是距离吗?
抑或者只是羞涩
和那么一点点没必要的尊严
我只知道那绝对不是什么畏惧、讨厌
因为此刻嘈杂的吵闹声也令我欢愉
真正的画家眼内只有景物别无他
真正的单相思者心中充满欲望受压抑
两人之间的那道咫尺不叫距离
而是一根连着心的琴弦
为了维系只好拉着
奏出没有四季的忧郁旋律

2008-2018,你好,开源时光机 | 开源中国10周年故事征集活动正在进行中

加载中
返回顶部
顶部