学生管理系统

来源:互联网 发布:JS window.returnvalue 编辑:程序博客网 时间:2024/06/05 04:38

在我亲爱的于老师感召下。。。。。。(好别扭啊)。。。写了一下这个学生管理系统。。还是cmd。。不过!!!!!!我终于能用Java写出可视化窗口了!!开心
这个程序也很简单。。。不过对于输入我没有进行错误判断。。。。因为C来写。。。错误真的很恶心,不像Java。。。所以恳求大家就按要求来..(可以将学生信息打印为excel表格哦)

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>struct node{    int score;    char name[110];    char student_id[100];    int order_num;    struct node *next;};struct node *head;///所有的信息链の开头/*************************************************                   主界面打印*************************************************/void show(){    for(int i = 1;i<=80;i++)    printf("*");    printf("\n");    printf("\t\t\t1:Creat a new sdutent file\n\n");///初始建立    printf("\t\t\t2:Display sdutent file\n\n");///展示    printf("\t\t\t3:Delet sdutent file\n\n");///删除    printf("\t\t\t4:Insert new sduten file\n\n");///插入    printf("\t\t\t5:Modify student file\n\n");///修改    printf("\t\t\t6:Printto excel form\n\n");///打印    printf("\t\t\t7:Game over\n\n");//结束     for(int i = 1;i<=80;i++)    printf("*");    printf("\n");}/*************************************************                 判断操作输入正误*************************************************/bool Judge_cho(char *cho){    if(strlen(cho) > 1)        return false;    if(cho[0] > '7'||cho[0] < '1')        return false;    return true;}/*************************************************                 初始录入学生信息*************************************************/struct node *Creat_file(){    system("cls");    printf("Please enter the number of student in the intital entry\n");    int sum,i;    struct node *p,*q,*head;    head = new node;    head -> next = NULL;    scanf("%d",&sum);    //getchar();    p = head;    for(i = 1;i <= sum; i++){        q = new node;        q -> order_num = i;        system("cls");        printf("Please enter No.%d student name: ",i);        scanf("%s",q -> name);        printf("Please enter No.%d student sdutent id: ",i);        scanf("%s",q -> student_id);        printf("Please enter No.%d student score: ",i);        scanf("%d",&q -> score);        q -> next = NULL;        p -> next = q;        p = q;    }    printf("Input complete!");    return head;}/*************************************************                   展示学生信息*************************************************/void Display_file(struct node *head){    struct node *p;    system("cls");    printf("\n\tOrder number\tStudent name\tStudent student_id\tStudent score\n");    p = head -> next;    while(p){         printf("\n\t%d\t\t%s\t\t%s\t\t%d\n",p -> order_num,p -> name,p -> student_id,p -> score);//        p = p -> next;     }    printf("\n\n\nPress any key to continue");    char a[100];    scanf("%s",a);}/*************************************************                  删除学生信息*************************************************/void Delet_file(struct node *head){    system("cls");    struct node *p,*q,*t;    printf("Please enter the number of students who need to delete student information\n");    char a[101];    scanf("%s",a);    p = head;    int flag = 0;    q = head -> next;    while(q){        if(strcmp(q -> student_id,a)==0){            flag = 1;            break;        }        p = q;        q = q -> next;    }    t = q -> next;    while(t){        t->order_num--;        t = t -> next;     }    if(flag){        p -> next = q -> next;        free(q);        printf("Delete success\n");    }    else        printf("Delete failed\nCan't find this student id\n");    Sleep(1000);    printf("\n\n\nPress any key to continue\n");    char b[10];    scanf("%s",b);}/*************************************************                  增添学生信息*************************************************/void Insert_new_file(struct node *head){    system("cls");    printf("Please enter the location where you want to add student information\n");    int n;    scanf("%d",&n);    struct node *q,*t,*p = head -> next;    t = head;    while(p -> order_num != n){        p = p -> next;        t = t -> next;    }    q = new node;    t -> next = q;    q -> next = p;     printf("Please enter the id of student to add\n");    scanf("%s",q -> student_id);    printf("Please enter the name of student to add\n");    scanf("%s",q -> name);    printf("Please enter the score of student to add\n");    scanf("%d",&q -> score);    q -> order_num = n;    while(p){        p -> order_num ++;        p = p -> next;    }    Sleep(1000);    printf("\n\n\nPress any key to continue\n");    char b[10];    scanf("%s",b);}/*************************************************                  修改学生信息*************************************************/void Modify_file(struct node *head){    struct node *p,*q;    system("cls");    printf("Please enter the number of students who need to modify student information\n");    char a[1010];    scanf("%s",a);    int flag = 0;    p = head -> next;    while(1){        if(strcmp(a,p -> student_id)){            flag = 1;            break;        }        else            p = p -> next;    }    if(flag){        while(1){            system("cls");            printf("Please enter the information you want to modify\n");            printf("1 -> student id\n");            printf("2 -> student socre\n");            printf("3 -> student name\n");             printf("4 -> exit routine\n");            int n;            scanf("%d",&n);            if(n == 1){                printf("Please enter a new student id\n");                scanf("%s",p -> student_id);            }            if(n == 2){                printf("Please enter a new student socre\n");                scanf("%d",&p->score);            }            if(n==3){                printf("Please enter a new student name\n");                scanf("%d",p -> name);            }               if(n==4)                break;        }        printf("Modify success\n");    }    else        printf("Modify failed\nCan't find this student id\n");    printf("\n\n\nPress any key to continue\n");    char b[10];    scanf("%s",b);}/*************************************************                  打印学生信息*************************************************/void Print_file(struct node *head){    FILE *fp = NULL;    fp = fopen("D:\\sdutent_information.xls","w");    struct node *p;    p = head -> next;    char a[100] = {"Order number"};    char b[100] = {"Student name"};    char c[100] = {"Student student_id"};    char d[100] = {"Student score"};    fprintf(fp,"%s\t%s\t%s\t%s\n",a,b,c,d);    while(p){        fprintf(fp,"%d\t%s\t%s\t%d\n",p -> order_num,p -> name,p -> student_id,p -> score);        p = p -> next;    }    fclose(fp);    printf("Print success\n");    printf("EXCEL named sdutent_information is in D disk\n");    printf("\n\n\nPress any key to continue\n");    char f[10];    scanf("%s",f);}/*************************************************                  主函数 *************************************************/int main(){    int flag = 0;     while(1){        if(flag==1)            break;        system("cls");        show();        char cho[10];        printf("\t\t\tPlease enter your choice: ");        scanf("%s",cho);        if(!Judge_cho(cho)){            system("cls");            printf("\n\n\n\n\n\n\t\t\t   Waring:illegal operation!\n");            Sleep(2000);            continue;        }        struct node *head;///所有的信息链の开头        switch(cho[0]){            case '1':                head = Creat_file();                break;            case '2':                Display_file(head);                break;            case '3':                Delet_file(head);                break;            case '4':                Insert_new_file(head);                break;            case '5':                Modify_file(head);                break;            case '6':                Print_file(head);                break;            case '7':                flag = 1;                break;        }    }    printf("hahahahahahahahahahahahha\n");    printf("2333333333333333333333333\n");}

等5月份上半月过去,就可以开心的,全身心的学Java啦!!!!哈哈哈哈哈

0 0
原创粉丝点击