用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c代码库

学生成绩管理系统 C语言版

2013-07-10 作者: 免费源代码下载整理举报

[c]代码库

#include"stdio.h"
#include"stddef.h"
#include"stddef.h"
#include"string.h"
#define MAX 10
typedef struct student {
    char name[MAX];
    int num[MAX];
    char sex[MAX];
    int chinese;
    int mathematic;
    int english;
    int computer;
    struct student *next;
} stu;
stu *head;
void print() {
    system("cls");
    printf("\t\t\tScore Manage System\n");
    printf("<1>Enter Record\t");
    printf("<2>Display\t");
    printf("<3>Insert\t");
    printf("<4>Quest\t");
    printf("<5>Update\t");
    printf("<6>Save\t");
    printf("<7>Fresh\t");
    printf("<8>Chinese Average\t");
    printf("<9>Math Average\t");
    printf("<10>English Average\t");
    printf("<11>Computer Average\t");
    printf("<12>Quit\t\n");
}

void cin(stu *p1) {
    printf("Enter name:\n");
    scanf("%s", &p1->name);
    printf("Enter num:\n");
    scanf("%d", &p1->num);
    printf("Enter sex:\n");
    scanf("%s", &p1->sex);
    printf("Enter score:\n");
    printf("Enter chinese:\n");
    scanf("%d", &p1->chinese);
    printf("Enter math:\n");
    scanf("%d", &p1->mathematic);
    printf("Enter English:\n");
    scanf("%d", &p1->english);
    printf("Enter Computer:\n");
    scanf("%d", &p1->computer);
}
stu *cindata() {
    stu *p1, *p2;
    int i = 1;
    char ch;
    p1 = (stu *)malloc(sizeof(stu));
    head = p1;
    while(i) {
        cin(p1);
        printf("Do you Want to Continue?yes or no");
        ch = getchar();
        ch = getchar();
        if(ch == 'n' || ch == 'N') {
            i = 0;
            p1->next = NULL;
        } else {
            p2 = p1;
            p1 = (stu *)malloc(sizeof(stu));
            p2->next = p1;
        }
    }
    return(p1->next);
}


void lookdata(stu *p1) {
    while(p1 != NULL) {
        printf("Num:%d\t", p1->num);
        printf("Name:%s\t", p1->name);
        printf("Sex:%s\t", p1->sex);
        printf("\n");
        printf("Chinese:%d\t", p1->chinese);
        printf("Math:%d\t", p1->mathematic);
        printf("English:%d\t", p1->english);
        printf("Computer:%d\t", p1->computer);
        printf("\n");
        p1 = p1->next;
    }

}



void insert(stu *p2) {
    stu *p1, *p3;
    char ch;
    int i = 1;
    p3 = (stu *)malloc(sizeof(stu));
    p1 = p2;
    while(i) {
        cin(p3);
        printf("Enter again?yes or no");
        ch = getchar();
        ch = getchar();
        if(ch == 'n' || ch == 'N') {
            i = 0;
            p3->next = NULL;
        } else {
            while(p1 != NULL)
                p1 = p1->next;
            p3 = (stu *)malloc(sizeof(stu));
            p1->next = p3;
        }
    }

}



find(stu *p2) {
    char name[20];
    int b = 0;
    printf("Enter the name of the student you want to find:");
    scanf("%s", name);
    while(p2 != NULL) {
        if(strcmp(name, p2->name) == 0) {
            printf("The data you want has be found\n");
            printf(" Name:%s\t", p2->name);
            printf("Num:%d\t", p2->num);
            printf("sex%s\t", p2->sex);
            printf("\n");
            printf("Chinese:%d\t", p2->chinese);
            printf("Math:%d\t", p2->mathematic);
            printf("English:%d\t", p2->english);
            printf("Computer:%d\t", p2->computer);
            printf("\n");

            b = 1;
        } else if(b == 0)
            printf("对不起,没有找到你要找的数据");
        p2 = p2->next;
    }

    if(b == 1) {
        print();
        printf("Find one\n");
    } else {
        print();
        printf("Not find\n");

    }
}


void caverage(stu *p2) {
    stu *p1;
    int i;
    float max = 0.0, min = 200.0;
    float sum = 0.0, aver = 0;
    p1 = p2;
    if(p1 == NULL)
        printf("not data!");
    else
        for(i = 0; p1 != NULL; i++, p1 = p1->next)
            sum += p1->chinese;
    aver /= i;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(max < p1->chinese)
            max = p1->chinese;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(min < p1->chinese)
            min = p1->chinese;
    printf("Chinese Average:%f", aver);
    printf("Chinese Max:%f", max);
    printf("Chinese Min:%f", min);
}




void maverage(stu *p2) {
    stu *p1;
    int i;
    float max = 0.0, min = 200.0;
    float sum = 0.0, aver = 0;
    p1 = p2;
    if(p1 == NULL)
        printf("not data!");
    else
        for(i = 0; p1 != NULL; i++, p1 = p1->next)
            sum += p1->mathematic;
    aver /= i;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(max < p1->mathematic)
            max = p1->mathematic;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(min < p1->mathematic)
            min = p1->mathematic;
    printf("Math Average:%f", aver);
    printf("Math Max:%f", max);
    printf("Math Min:%f", min);
}


void eaverage(stu *p2) {
    stu *p1;
    int i;
    float max = 0.0, min = 200.0;
    float sum = 0.0, aver = 0;
    p1 = p2;
    if(p1 == NULL)
        printf("not data!");
    else
        for(i = 0; p1 != NULL; i++, p1 = p1->next)
            sum += p1->english;
    aver /= i;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(max < p1->english)
            max = p1->english;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(min < p1->english)
            min = p1->english;
    printf("English avergre:%f", aver);
    printf("English Max:%f", max);
    printf("English Min:%f", min);
}


void comaverage(stu *p2) {
    stu *p1;
    int i;
    float max = 0.0, min = 200.0;
    float sum = 0.0, aver = 0;
    p1 = p2;
    if(p1 == NULL)
        printf("not data!");
    else
        for(i = 0; p1 != NULL; i++, p1 = p1->next)
            sum += p1->computer;
    aver /= i;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(max < p1->computer)
            max = p1->computer;
    for(i = 0; p1 != NULL; i++, p1 = p1->next)
        if(min < p1->computer)
            min = p1->computer;
    printf("Computer Averger:%f", aver);
    printf("Computer Max:%f", max);
    printf("Computer Min:%f", min);
}


update(stu *p2) {
    char name[10];
    int b = 0;
    printf("Enter The Name");
    scanf("%s", name);

    while(p2 != NULL) {
        if(strcmp(name, p2->name) == 0) {
            printf("Find you data\n");
            scanf("Name:%s", p2->name);
            scanf("Num:%s", p2->num);
            scanf("Sex:%s", p2->sex);
            scanf("Chinese:%d", p2->chinese);
            scanf("Math:%d", p2->mathematic);
            scanf("english:%d", p2->english);
            scanf("Computer:%d", p2->computer);
            printf("Success!");

            b = 1;
        } else if(b == 0)
            printf("Sorry not Find data!");
        p2 = p2->next;
    }
    if(b == 0) {
        print();
        printf("Sorry not Find data!");
    } else {
        print();
        printf("Finish!");
    }
}



save(stu *p2) {
    FILE *fp;
    char file[10];
    printf("Enter file name");
    scanf("%s", file);
    fp = fopen(file, "w");
    while(p2 != NULL) {
        fprintf(fp, "%s", p2->name);
        fprintf(fp, "%s", p2->num);
        fprintf(fp, "%s", p2->sex);
        fprintf(fp, "%d", p2->chinese);
        fprintf(fp, "%d", p2->mathematic);
        fprintf(fp, "%d", p2->english);
        fprintf(fp, "%d", p2->computer);
        p2 = p2->next;
    }
    fclose(fp);
}


char password[7] = "123456";


void main() {
    int choice;
    stu *p2;
    char s[8];
    int flag = 0, i;
    int n = 3;
    do {
        printf("Enter password:\n");
        scanf("%s", s);
        if(!strcmp(s, password)) {
            printf("PASS\n\n\n");
            flag = 1;
            break;
        } else {
            printf("Error Enter again:\n");
            n--;
        }
    } while(n > 0);
    if(!flag) {
        printf("you have Enter 3 times!");
        exit(0);
    }


    printf("~~~~~~~~~~\t\t\t~~~~~~~~~~~~\n");
    printf("\t\tWelcom to the Mis\n");
    printf("Author:-----\tClass:------\tNum:------\n");
    printf("Adress:HG\n");
    printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
    printf("\t\tEnter OP:\n");
    printf("\n\n\n\n");
    printf("==============\t\t==============\n");
    printf("==============\t\t==============\n");
    printf("\t\tEnter the MIS yes or no\n");

    scanf("%d", &choice);
    if(choice == 'n' || choice == 'N')
        exit(1);

    print();
    while(1) {
        printf("Enter choice:");
        scanf("%d", &i);
        if(i < 1 || i > 8) {
            printf("Enter num from 1 to 8:\n");
            exit(1);
        }

        switch(i) {
        case 1:
            p2 = cindata();
            break;
        case 2:
            lookdata(head);
            break;
        case 3:
            insert(p2);
            break;
        case 4:
            find(head);
            break;
        case 5:
            update(head);
            break;
        case 6:
            save(head);
            break;
        case 7:
            print();
            break;
        case 8:
            caverage(head);
            break;
        case 9:
            maverage(head);
            break;
        case 10:
            eaverage(head);
            break;
        case 11:
            comaverage(head);
            break;
        case 12:
            ;
        case 13:
            exit(1);
            break;

        }
        scanf("%d", &i);
    }



}


网友评论    (发表评论)

共3 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...