Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

王天锐 #38

Open
wangtianrui opened this issue Nov 2, 2016 · 1 comment
Open

王天锐 #38

wangtianrui opened this issue Nov 2, 2016 · 1 comment

Comments

@wangtianrui
Copy link
Member

学生信息管理系统

#include<stdio.h>
#include<string.h>
#define LEN sizeof(struct student)
struct student
{
    char name[20];
    int num ;
    int score;
    struct student *next ;
};
struct student *head , *p  , *m  , *x ;

void shanchu(struct student *x)
{
    struct student *ted ;
    int i = 1 ;
    char ID[20] ;
    printf("输入想删除学生的姓名:");
    scanf("%s", ID );
    ted = head ;
    while(ted)
    {
       if( strcmp(ted->name,ID)==0 )
       {
           if( i == 1 )
           {
               head = head->next ;
           }
           else
           {
               m->next = ted->next;
               free(ted);
           }
       }
        m = ted ;
        ted = ted->next ;
        i = i + 1 ;
    }

}

void shuchu( struct student *x )
{
    struct student *ted ;
    ted = head ;
    while(ted)
    {
        printf("%s的学号为:%d\t成绩为:%d\n", ted->name , ted->num , ted->score);
        ted = ted->next ;
    }

}


void creat()
{
    p = (struct student *)malloc( LEN ) ;
    printf("请按照姓名,学号,分数的顺序输入。若需停止则输入 stop 0 0\n");
    scanf("%s %d %d", p->name , &p->num , &p->score );
    head = p ;
    while( strcmp( p->name , "stop") != 0 )
    {
        m = p ;
        p = (struct student *)malloc( LEN ) ;
        scanf("%s %d %d", p->name , &p->num , &p->score );
        m->next = p ;
    }
    p->next = NULL;
}



int main()
{
    int i  , j  , n ;
    for( i = 1 ; i <= 100 ; i++)
    {
        printf("_");
        if( i == 50 )
        {
            printf("\n");
            for( j = 1 ; j <= 16 ; j ++)
            {
                printf(" ");
            }
            printf("学生学籍管理系统");
             for( j = 1 ; j <= 16 ; j ++)
            {
                printf(" ");
            }
            printf("\n");
            for( j = 1 ; j <= 16 ; j++)
            {
                printf(" ");
            }
            printf("1.学生学号的添加。");
            for( j = 1 ; j <= 15 ; j ++)
            {
                printf(" ");
            }
            printf("\n");
            for( j = 1 ; j <= 16 ; j++)
            {
                printf(" ");
            }
            printf("2.学生学号的查看。");
             for( j = 1 ; j <= 15 ; j ++)
            {
                printf(" ");
            }
            printf("\n");
            for( j = 1 ; j <= 16 ; j++)
            {
                printf(" ");
            }
            printf("3.学生学号的删除。");
             for( j = 1 ; j <= 15 ; j ++)
            {
                printf(" ");
            }
            printf("\n");


        }
    }
    printf("\n\n\n");
    for( i = 1 ; i <= 1000 ; i++)
    {
        scanf("%d", &n );
        switch(n)
        {
            case 1 : creat();break ;
            case 2 : shuchu( head );break ;
            case 3 : shanchu( head );break ;
            default : printf("请输入正确的选项\n");continue;
        }
    }
    return 0 ;
}
@Feng-YuanQing
Copy link

hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants