精华内容
下载资源
问答
  • Linux下Shell编程实现学生信息管理系统
    2021-05-10 07:48:34

    #! /bin/sh

    insert_s()

    {

    file_name="/root/aillo/students.db"

    dialog --title "Student: Insert a record " --inputbox "Please input the student's information in the sort:(id,name,college):" 20 50 2>tmp.txt

    content=$(cat tmp.txt)

    IFS=","

    read sid sname sin

    unset IFS

    grep -c "$sid" $file_name>menu.txt

    sid=$(cat menu.txt)

    if [ "$sid" != "0" ];then

    dialog --title "ERROR" --msgbox "Record has existed!" 20 30

    else

    echo "$content">>$file_name

    dialog --title "Reply Info" --msgbox "Add successfully!" 10 30

    fi

    }

    insert_c()

    {

    file_name="/root/aillo/colleges.db"

    dialog --title "College: Insert a record " --inputbox "Please input the college's information in the sort(cid,cname):" 20 50 2>tmp.txt

    content=$(cat tmp.txt)

    IFS=","

    read cid cname

    unset IFS

    grep -c "$cid" $file_name>tmp.txt

    cid=$(cat tmp.txt)

    if [ "$cid" != "0" ];then

    dialog --title "ERROR" --msgbox "Record has existed!" 30 50

    else

    echo "$content">>$file_name

    dialog --title "Reply Info" --msgbox "Add successfully!" 10 30

    fi

    }

    delete_s()

    {file_name="/root/aillo/students.db"

    dialog --title "Student: Delete a record " --inputbox "Please input the ID of the student you want to delete:" 20 50 2>tmp.txt

    read sid

    grep -v $sid $file_name>tmp.txt

    mv tmp.txt $file_name

    dialog --title "Reply Info" --msgbox "the record has been delete!" 10 30

    }

    delete_c()

    {file_name="/root/aillo/colleges.db"

    dialog --title "College: Delete a record " --inputbox "Please input the ID of the college you want to delete:" 20 50 2>tmp.txt

    read cid

    grep -v $cid $file_name>tmp.txt

    mv tmp.txt $file_name

    dialog --title "Reply Info" --msgbox "the record has been delete!" 10 30

    }

    display_s()

    {file_name="/root/aillo/students.db"

    cat $file_name | while read line

    do

    echo $line>tmp.txt

    IFS=","

    read sid sname sin

    echo "sid: $sid">>t.txt

    echo "sname: $sname">>t.txt

    echo "sin: $sin">>t.txt

    echo "---------------------">>t.txt

    IFS=" "

    done

    content=$(cat t.txt)

    dialog --title "All Students' Info" --msgbox "$content" 50 50

    rm t.txt

    }

    display_c()

    {file_name="/root/aillo/colleges.db"

    cat $file_name | while read line

    do

    echo $line>tmp.txt

    IFS=","

    read cid cname

    echo "cid: $cid">>t.txt

    echo "cname: $cname">>t.txt

    echo "---------------------">>t.txt

    IFS=" "

    done

    content=$(cat t.txt)

    dialog --title "All colleges' Info" --msgbox "$content" 50 50

    rm t.txt

    }

    count()

    {

    file_name="/root/aillo/students.db"

    dialog --title "Count " --inputbox "Please input the id of college students you want to count:" 20 50 2>tmp.txt

    read p1

    dialog --title "Reply Info" --msgbox "There are `grep -c $p1 $file_name` students in the $p1 college!" 10 30

    }

    change_s()

    {

    file_name="/root/aillo/students.db"

    dialog --title "Modify Student's Info " --inputbox "Please input the new information you want to modify in the sort(sid,sname,sin):" 20 50 2>tmp.txt

    IFS=","

    read p1 p2 p3

    grep -v $p1 $file_name>tmp.txt

    echo "$p1,$p2,$p3">>tmp.txt

    IFS=" "

    mv tmp.txt $file_name

    dialog --title "Reply Info" --msgbox "The information has been modified!" 10 30

    }

    change_c()

    {

    file_name="/root/aillo/colleges.db"

    dialog --title "Modify College's Info" --inputbox "Please input the new information:" 20 50 2>tmp.txt

    IFS=","

    read p1 p2

    grep -v $p1 $file_name>tmp.txt

    echo "$p1,$p2">>tmp.txt

    IFS=" "

    mv tmp.txt $file_name

    dialog --title "Reply Info" --msgbox "The information has been modified!" 10 30

    }

    status=1

    dialog --title " Students' Info Manage System" --msgbox "\\nWelccome to use the System!\\n" 10 35

    if [ $? != 0 ];then

    sleep 1

    dialog --clear

    exit 0

    fi

    while [ "$status" = "1" ]

    do

    dialog --title "Main Menu" --menu "Choices" 15 20 2 1 "Student" 2 "College" 2>tmp.txt

    MY_CHOICE=$(cat tmp.txt)

    if [ $? != 0 ];then

    sleep 1

    dialog --clear

    exit 0

    fi

    if [ "$MY_CHOICE" = "1" ];then

    dialog --title "Student Info Manage" --menu "Choose Operation" 20 30 7 1 "INSERT" 2 "DELETE" 3 "MODIFY" 4 "COUNT" 5 "DISPLAY" 6 "BACK" 7 "EXIT" 2>tmp.txt

    if [ $? != 0 ];then

    sleep 1

    dialog --clear

    exit 0

    fi

    choice_2=$(cat tmp.txt)

    if [ "$choice_2" = "1" ];then

    insert_s

    elif [ "$choice_2" = "2" ];then

    delete_s

    elif [ "$choice_2" = "3" ];then

    change_s

    elif [ "$choice_2" = "4" ];then

    count

    elif [ "$choice_2" = "5" ];then

    display_s

    elif [ "$choice_2" = "6" ];then

    continue

    else

    break

    fi

    else

    dialog --title "College Info Manage" --menu "Choose Operation" 20 30 7 1 "INSERT" 2 "DELETE" 3 "MODIFY" 4 "COUNT" 5 "DISPLAY" 6 "BACK" 7 "EXIT" 2>tmp.txt

    if [ $? != 0 ];then

    sleep 1

    dialog --clear

    exit 0

    fi

    choice_2=$(cat tmp.txt)

    if [ "$choice_2" = "1" ];then

    insert_c

    elif [ "$choice_2" = "2" ];then

    delete_c

    elif [ "$choice_2" = "3" ];then

    change_c

    elif [ "$choice_2" = "4" ];then

    count

    elif [ "$choice_2" = "5" ];then

    display_c

    elif [ "$choice_2" = "6" ];then

    continue

    else

    break

    fi

    fi

    dialog --yesno "Do you want to continue ?" 10 20

    if [ $? = 0 ];then

    status=1

    else

    status=0

    fi

    done

    sleep 1

    dialog --clear

    exit 0

    更多相关内容
  • 学生信息管理系统,包括密码,插入,保存的,等。文件自己创建。
  • 学习C语言过程中写的一个练习,对C语言入门的初学者有所帮助,很有参考价值,在linux系统下可直接编译运行。
  • 实用标准文档 Linux 课程设计报告 班级 学号 姓名 2012 年 6 月 3 日 文案大全 实用标准文档 一 设计目标 课程设计为学生信息管理系统 主要功能是对教师和学生信息的综合管理以及对 学生成绩的综合管理 本学生信息...
  • 文件挺多的,先是在data文件夹中有创建初始学生资料的create_data.c(测试用,不需要跑)和一堆二进制保存的学生信息、教师信息 sams文件夹中,管理员窗口文件、学生窗口文件、教室窗口文件、工具文件,全是.h和.c...
  • 1、主程序模块主要功能:程序的入口主要文件:main.c2、菜单模块主要功能:完成菜单的显示和调用相应功能函数主要文件:menu.h menu.c3、学生模块主要功能:完成学生结构定义,添加学生,删除学生,修改学生,查找...
  • 主要为大家详细介绍了linux下c/c++学生信息管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • 包含数据库mysql readline log文件 配置文件 密码回显
  • C语言学了四周了,试着做了学生信息管理系统。只有增删查改读出和写入功能。大佬勿喷。小弟谢过了。
  • 基于LINUX的大学生成长信息管理系统设计与实现.pdf
  • 学习并分别使用标准 C的文件操作函数和Linux系统调用创建一个对学生基本信息进行操 作插入修改和删除的 C程序学生基本信息以结构体的形式存储在文件 #include<stdio.h> #include<unistd.h> #include<string.h> #...
  • linux编写学生管理系统

    千次阅读 2020-08-30 13:24:19
    头文件与宏定义 #include <stdio.h> #include <... //定义浏览学生信息的个数 定义学生信息结构体与声明函数 //定义学生信息结构体 typedef struct student { char name[30]; //学生姓名 char s

    头文件与宏定义

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define MAX  30   //宏定义最大学生人数
    
    //定义全局变量
    int num=0; //定义学生编号
    int x=0;  //定义浏览学生信息的个数
    
    

    定义学生信息结构体与声明函数

    //定义学生信息结构体
    typedef struct student
    {
    	
    	char name[30]; //学生姓名
    	char sex[10];  //学生性别
    	int age;      //学生年龄
    	long int number;  //学生学号
    	int record;     //学生成绩
    	 
    }th_note;
    
    //声明函数
    void add(th_note *a);
    void delete(th_note *a);
    void inquire(th_note *a);
    void amend(th_note *a);
    void look(th_note *a);
    

    功能函数块

    /*-------------------------------------------------
                    增加学生数据
    -------------------------------------------------*/
    void add(th_note *a)
    {
    	printf("============================\n");
    	printf("请输入你要增加的学生的编号1~%d\n",MAX);
    	scanf("%d",&num);
    	if(num>0 && num<=MAX)    //判断是否超出学生的最大人数
    	{
    		printf("请输入你要增加的学生的姓名\n");
    	    scanf("%s",(a+num)->name);
    	    printf("请输入你要增加的学生的性别\n");
    	    scanf("%s",(a+num)->sex);
            printf("请输入你要增加的学生的年龄\n");
    	    scanf("%d",&(a+num)->age);
            printf("请输入你要增加的学生的学号\n");
    	    scanf("%ld",&(a+num)->number);
    	    printf("请输入你要增加的学生的成绩\n");
    	    scanf("%d",&(a+num)->record);
    	   
    	    printf("增加的学生数据:\n编号:%d \t名字:%s \t性别:%s \t年龄:%d \t学号:%ld \t成绩:%d \n",
    		    num,
                (a+num)->name,
                (a+num)->sex,
                (a+num)->age,
                (a+num)->number,
                (a+num)->record
               );
    	    x++;
    	  
    	    printf("增加成功\n");
    	   
    	}
    	else
    		printf("增加失败\n");
    	
    	printf("\n");
    }
    
    /*-------------------------------------------------
                    删除学生数据
    -------------------------------------------------*/
    void delete(th_note *a)
    {
    	printf("============================\n");
    	printf("请输入你要删除的学生的编号1~%d\n",MAX);
    	scanf("%d",&num);
    
    	if(0<num && num<=MAX)
    	{
    		strcpy((a+num)->name,"0");
    	    strcpy((a+num)->sex,"0");
    	    (a+num)->age='\0';
    	    (a+num)->number='\0';
    	    (a+num)->record='\0';
    		
            printf("删除成功!\n");
    	}
        else
         printf("删除失败!\n");
    
         printf("\n");
    }
    
    /*-------------------------------------------------
                    查询学生数据
    -------------------------------------------------*/	
    
    void inquire(th_note *a)
    {
    	printf("============================\n");
    	printf("请输入你要查询的学生的编号1~%d\n",MAX);
    	scanf("%d",&num);
    	if(0<num && num<=MAX)
    	{
    		printf("编号:%d \t名字:%s \t性别:%s \t年龄:%d \t学号:%ld \t成绩:%d \n",
    		       num,
                   (a+num)->name,
                   (a+num)->sex,
                   (a+num)->age,
                   (a+num)->number,
                   (a+num)->record
                   );		
    	     
    	}
        else
         printf("暂无学生信息!\n");
     
         printf("\n");
    }
    
    
    /*-------------------------------------------------
                    修改学生数据
    -------------------------------------------------*/
    void amend(th_note *a)
    {
    	printf("============================\n");
    	printf("请输入你要修改的学生的编号1~%d\n",MAX);
    	scanf("%d",&num);
    	if(0<num && num<=MAX)
    	{
    		printf("修改学生数据前的学生数据为:\n");
    		printf("编号:%d \t名字:%s \t性别:%s \t年龄:%d \t学号:%ld \t成绩:%d \n",
    		       num,
                   (a+num)->name,
                   (a+num)->sex,
                   (a+num)->age,
                   (a+num)->number,
                   (a+num)->record
                   );
    		printf("请输入你要修改的学生的姓名\n");
    	    scanf("%s",(a+num)->name);
    	    printf("请输入你要修改的学生的性别\n");
    	    scanf("%s",(a+num)->sex);
            printf("请输入你要修改的学生的年龄\n");
    	    scanf("%d",&(a+num)->age);
            printf("请输入你要修改的学生的学号\n");
    	    scanf("%ld",&(a+num)->number);
    	    printf("请输入你要修改的学生的成绩\n");
    	    scanf("%d",&(a+num)->record);
    
            printf("修改学生数据后的学生数据为:\n");
    	    printf("编号:%d \t名字:%s \t性别:%s \t年龄:%d \t学号:%ld \t成绩:%d \n",
    		       num,
                   (a+num)->name,
                   (a+num)->sex,
                   (a+num)->age,
                   (a+num)->number,
                   (a+num)->record
                   );
    
    	     
    	}
        else
         printf("暂无学生信息,无法修改!\n");
     
         printf("\n");
    }
    
    /*-------------------------------------------------
                    浏览学生信息
    -------------------------------------------------*/
    void look(th_note *a)
    {
    	printf("=============================学生信息==============================\n");
    	if(x!=0)
    	{
    		for(num=1;num<=x;num++)
    	    {
    	        printf("编号:%d \t名字:%s \t性别:%s \t年龄:%d \t学号:%ld \t成绩:%d \n",
    		          num,
                      (a+num)->name,
                      (a+num)->sex,
                      (a+num)->age,
                      (a+num)->number,
                      (a+num)->record
                      );
    	    }
    	}
    	else
    		printf("无学生信息\n");
    
    	printf("\n");
    	 
    }
    

    主函数

    int main(int argc, char const *argv[])
    {
    
    	th_note *a =(struct student*)malloc(sizeof(struct student)*100);
     
         
      //主页面
    	printf("========学生管理系统========\n");
    
    labe:
    	printf("============================\n");
    	printf("1.增加学生数据\n2.删除学生数据\n3.查询学生数据\n4.修改学生数据\n5.浏览学生信息\n6.退出\n");
    	printf("============================\n");
    
    
        int  n;
    
        do
        {
        	printf("请输入你想要的操作\n");
    	    scanf("%d",&n);
    	    if (n<=0||n>6)
    	    {
    	    	printf("你输入的数据有误,请重新输入数据!!\n");
    		    goto labe;
    	    }
    	
    		switch(n)
    		{
    			case 1:
    			printf("请输入你要增加的学生数据\n");
    			add(a);
                
                break;
    			case 2:
                printf("请输入你要删除的学生数据\n");
                delete(a);
                
                break;
    			case 3:
    			printf("请输入你要查询的学生数据\n");
                inquire(a);
                
                break;
    			case 4:
    			printf("请输入你要修改的学生数据\n");
                amend(a);
    
                break;
                case 5:
                look(a);
                break;
    
    			default:
    			printf("你已退出系统\n");
    		}
            
    
        }while(n<6);
    
    	
    	free(a);
    
    	return 0;
    }
    
    展开全文
  • QT做的学生信息管理系统

    热门讨论 2009-12-17 19:23:03
    QT做的学生信息管理系统,适合初学者。 1.运行环境 LINUX Redhat 2.应用软件 QT 3.1.1 3.数据库 sqlite3.08 使用方法: 1.把QT的库路径设在 /usr/lib/qt-3.1/lib 下 2.把sqlite3的库路径设在 /usr/local/sqlite01...
  • 本文为大家分享了C语言学生信息管理系统小项目,供大家参考,具体内容如下 /* 运行环境:我是在linux里面用gcc编译的,在windows里应该也能运行,用的一些文件库函数都是c标准库,没有用linux的系统调用(纠正一下...
  • 基于Ubuntu14.04 环境开发,采用Mysql数据库,将数据库文件导入运行,程序分为服务端和客户端,服务端有两个功能,一个是监听客户端连接,第二个是管理员操作,可以对学生增删查改。客户端主要是学生可以通过网络...
  • LINUX下的C学生信息管理系统

    千次阅读 2017-11-16 20:05:45
    第一次写,难免会有些紧张 ,这是我们的课程设计作业,拉出来分享下。 -_- 大一的代码看起来真特么丑 /* 版本号 V1.0 时间 2014.6.24*/ #include #include ... printf("学生信息未找到!\n");...

    第一次写,难免会有些紧张 ,这是我们的课程设计作业,拉出来分享下。 -_- 大一的代码看起来真特么丑

    /* 
        版本号 V1.0
        时间 2014.6.24*/
    
    #include<stdio.h>
    #include<stdlib.h>
    #include<malloc.h>
    #include<string.h>
    #define SI sizeof(stu)
    #define PT "^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^ ^…^\n"
    #define ET "|%-15s|%-14ld|%-9s|%-8d|%-8d|%-14ld|%-6.1f|%-6.1f|%-6.1f|%-6.1f|%6.1f|%6.1f|%6.1f|\n绩点:                                                         |%-6.1f|%-6.1f|%-6.1f|%-6.1f|%-6.1f|\n",node->name,node->num,node->sex,node->age,node->bir,node->tel,node->score[0],node->score[1],node->score[2],node->score[3],node->score[4],node->sum,node->ave,node->gpa[0],node->gpa[1],node->gpa[2],node->gpa[3],node->gpa[4]
    
    void clear(void)    //清屏函数
    {
        system("clear");
    }
    typedef struct s
    {
        long num;    //学号
        char name[20];    //姓名
        char sex[5];    //性别
        int age;    //年龄
        int bir;        //生日
            long tel;        //电话号码
        float score[5];    //五门成绩
        float ave;    //平均分
        float gpa[5];    //绩点
        float sum;    //总分数
        char pass[15];
        struct s * next;
    
    }stu;
    
    typedef struct passw
    {
        long num;
        char pass[15];
        struct passw *next;
    }DI;
    
    stu * creat()        //创建链表
    {
        stu* head,*node,*new_node;
        FILE *fp;
            fp=fopen("os.txt","w+");
            if((fp==NULL))
            {
                    printf("加载失败!\n");
                    exit(0);
            }
    
        head = node = (stu *)malloc(SI);
        new_node = (stu *)malloc(SI);
        printf("\n|学生姓名  |学号  |姓别 |年龄 |生日 |电话号码   |高数 |英语 |离散 |大物 |C语言:\n");
            scanf("%s %ld %s %d %d %ld %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4]);
        int i;
            float sum=0;
            for (i=0;i<5;i++)
            {     
                    sum+=new_node->score[i];
                    if (new_node->score[i]<60)
                           new_node->gpa[i] = 0; 
                    else
                           new_node->gpa[i] = new_node->score[i]/10-5;
                    
            }
            new_node->ave = sum/5;
        new_node->sum = sum;
    while (new_node->num!=0)
    {
        node->next = new_node;
        node = new_node;
        new_node = (stu *)malloc(SI);
        printf("\n|学生姓名  |学号  |姓别 |年龄 |生日 |电话号码   |高数 |英语 |离散 |大物 |C语言:\n");
            scanf("%s %ld %s %d %d %ld %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4]);
            int i;
            float sum=0;
            for (i=0;i<5;i++)
            {
                    sum+=new_node->score[i];
                    if (new_node->score[i]<60)
                           new_node->gpa[i] = 0;
                    
                    else
                           new_node->gpa[i] = new_node->score[i]/10-5;
                    
            }
            new_node->ave = sum/5;
        new_node->sum = sum;
    }
    node->next = NULL;
    free(new_node);
    fclose(fp);
    return head;
    }
    
    void write(stu *head)
    {
        stu *new_node;
        new_node = head->next;
        FILE *fp;
        if((fp = fopen("os.txt","w+"))==NULL)
        {
            printf("加载失败!\n");
            exit(0);
        }
    while(new_node!=NULL)
    {    
        fprintf(fp,"%-15s%-14ld%-9s%-8d%-8d%-14ld%-6.1f%-6.1f%-6.1f%-6.1f%-6.1f%-6.1f%-6.1f%-4.1f%-4.1f%-4.1f%-4.1f%-4.1f\n",new_node->name,new_node->num,new_node->sex,new_node->age,new_node->bir,new_node->tel,new_node->score[0],new_node->score[1],new_node->score[2],new_node->score[3],new_node->score[4],new_node->sum,new_node->ave,new_node->gpa[0],new_node->gpa[1],new_node->gpa[2],new_node->gpa[3],new_node->gpa[4]);
        new_node = new_node->next;
    
    }
        fclose(fp);
    }
    
    stu *read(void)        //从文件中读取信息并创建链表
    {
         stu* head,*node,*new_node;
        FILE *fp;
            fp=fopen("os.txt","r");
            if((fp==NULL))
            {
                    printf("加载失败!\n");
                    exit(0);
            }
        head = node = (stu *)malloc(SI);
            new_node = (stu *)malloc(SI);
        fscanf(fp,"%s %ld %s %d %d %ld %f %f %f %f %f %f %f %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4],&new_node->sum,&new_node->ave,&new_node->gpa[0],&new_node->gpa[1],&new_node->gpa[2],&new_node->gpa[3],&new_node->gpa[4]);
        while(!feof(fp))
        {
            node->next = new_node;
            node = new_node;
            new_node = (stu *)malloc(SI);
             fscanf(fp,"\n%s %ld %s %d %d %ld %f %f %f %f %f %f %f %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4],&new_node->sum,&new_node->ave,&new_node->gpa[0],&new_node->gpa[1],&new_node->gpa[2],&new_node->gpa[3],&new_node->gpa[4]);
        }
        node->next = NULL;
        free(new_node);
        fclose(fp);
        return(head);
    }
    
    stu *findnum(void)   //其中num为要查找的学生的学号
    {
        long num;
        printf("查找的学号:");
        scanf("%ld",&num);
        stu *node;
        node = read();
        while (node->next!=NULL)
        {    
            node = node->next;
            if (node->num == num)
            {       printf(PT);
                            printf(ET);
                return node;
                    }
    
        }
        printf("学生信息未找到!\n");
        return NULL;
        
    }
    
    stu *findname(void)   //其中num为要查找的学生的姓名
    {
        char name[20];
        printf("查找的姓名:");
        scanf("%s",name);
            stu *node;
            node = read();
        int cmp;
            while (node->next!=NULL)
            {
            node = node->next;
                    cmp = strcmp(name,node->name);
            if(cmp == 0)
            {    printf(PT);
                            printf(ET);
                return node;
            }
            }
            printf("学生信息未找到!\n");
        return 0;
            
    }
    
    void find()
    {
        printf("\t\t\t1.姓名查找.\n\t\t\t2.学号查找.\n\t\t\t0.回到上层.\n");
        int i;
        scanf("%d",&i);
        switch(i)
        {
            case 1: findname();break;
            case 2: findnum();break;
            case 3: begin();break;
            default :printf("错误!\n");begin();
        }
    }
    
    stu *deletenum(void)
    {
        long num;
        printf("输入要删除学生的学号:");
        scanf("%ld",&num);
        stu *head,*node,*no;
        head = no = read();
        node = no->next;
        while(node!=NULL)
           { if(node->num==num)
            {
                no->next = node->next;
                free(node);
                printf("删除成功!\n");
                write(head);
                return head;
            }
             no = node;
             node = node->next;
           }
           printf("删除失败!\n");
    }
    
    stu *deletename(void)
    {
            char name[20];
            printf("输入要删除学生的姓名:");
            scanf("%s",name);
            stu *head,*node,*no;
            head = no = read();
            node = no->next;
            while(node!=NULL)
               { if(strcmp(node->name,name)==0)
                    {
                            no->next = node->next;
                            free(node);
                            printf("删除成功!\n");
                            write(head);
                            return head;
                    }
                 no = node;
                 node = node->next;
               }
               printf("删除失败!\n");
    }
    
    void delete()
    {
            printf("\t\t\t1.按学号删除.\n\t\t\t2.按姓名查找.\n\t\t\t0.回到上层.\n");
            int i;
            scanf("%d",&i);
            switch(i)
            {
                    case 1: deletenum();break;
                    case 2: deletename();break;
                    case 3: begin();break;
                    default :printf("错误!\n");begin();
            }
    }
    
    stu* sortsum()
    {
        stu *head = read();
        stu *p,*q,*pt,*t;
        t = (stu *)malloc(SI); // 创建临时结点 
        t->next = head; // 临时结点作为链表临时头指针 
        for(p = head; p->next!=NULL; p = p->next) 
        {
            q = p->next;
            while(q->next!=NULL)
            {
                if(p->next->sum < q->next->sum)
                {
                    pt = p->next;
                    p->next = q->next;
                    q->next = p->next->next;
                    p->next->next = pt;
                }
                else q = q->next;
            }
        }
        head = t->next;
        free(t);
        write(head);
        return head;
    
    }
    
    stu* sortnum()
    {
        stu *p,*q,*pt,*t,*head;
        head = read();
        t = (stu *)malloc(SI); // 
        t->next = head; // 
        for(p = head; p->next!=NULL; p = p->next) 
        {
            q = p->next;
            while(q->next!=NULL) 
        {
                if(p->next->num > q->next->num) 
            {
                    pt = p->next;
                    p->next = q->next;
                    q->next = p->next->next;
                    p->next->next = pt;
                }
                else q = q->next;
            }
        }
        head = t->next;
        free(t);
        write(head);
    }
    
    stu* add(void)
    {
        DI *fr();
        FILE *fp;
        if ((fp = fopen("pass.txt","a+"))==NULL)
            {
                    printf("打开文件失败!\n");
                    exit(0);
            }
        stu *head,*new_node,*node;
        DI *head1;
        DI *node1,*new_node1;
        head = read();
        head1 = fr();
        node = head->next;
        node1 = head1->next;
        while (node1->next!=NULL)
            node1 = node1->next;
        while(node->next!=NULL)
            node = node->next;
        new_node = (stu *)malloc(SI);
        printf("\n|学生姓名  |学号  |姓别 |年龄 |生日 |电话号码   |高数 |英语 |离散 |大物 |C语言:\n");
            scanf("%s %ld %s %d %d %ld %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4]);
        int i;
            float sum=0;
            for (i=0;i<5;i++)
            {
                    sum+=new_node->score[i];
                    if (new_node->score[i]<60)
                           new_node->gpa[i] = 0;
    
                    else
                           new_node->gpa[i] = new_node->score[i]/10-5;
    
            }
            new_node->ave = sum/5;
            new_node->sum = sum;
        new_node1 = (DI *)malloc(sizeof(DI));
        new_node1->num = new_node->num;
        strcpy(new_node1->pass,"000000");
        fprintf(fp,"%ld %s\n",node->num,new_node1->pass);
        while (new_node->num!=0)
    {
        node->next = new_node;
        node1->next = new_node1;
        node = new_node;
        node1 = new_node1;
        new_node = (stu *)malloc(SI);
            printf("\n|学生姓名  |学号  |姓别 |年龄 |生日 |电话号码   |高数 |英语 |离散 |大物 |C语言:\n");
            scanf("%s %ld %s %d %d %ld %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4]);
        int i;
    
            {
                    sum+=new_node->score[i];
                    if (new_node->score[i]<60)
                           new_node->gpa[i] = 0;
    
                    else
                           new_node->gpa[i] = new_node->score[i]/10-5;
    
            }
            new_node->ave = sum/5;
            new_node->sum = sum;
        new_node1 = (DI *)malloc(sizeof(DI));
            new_node1->num = new_node->num;
            strcpy(new_node1->pass,"000000");
        fprintf(fp,"%ld %s\n",node->num,new_node1->pass);
    }
        node->next = NULL;
        free(new_node);
        free(new_node1);
        write(head);
        fclose(fp);
        printf("文件插入保存成功");
        return head;
    }
    
    void mod()
    {
        stu *new_node,*node,*head,*no;
        new_node = (stu *)malloc(SI);
        printf("输入要修改学生的信息\n|学生姓名  |学号  |姓别 |年龄 |生日 |电话号码   |高数 |英语 |离散 |大物 |C语言:\n");
        scanf("%s %ld %s %d %d %ld %f %f %f %f %f",new_node->name,&new_node->num,new_node->sex,&new_node->age,&new_node->bir,&new_node->tel,&new_node->score[0],&new_node->score[1],&new_node->score[2],&new_node->score[3],&new_node->score[4]);
        int i;
            float sum=0;
            for (i=0;i<5;i++)
            {
                    sum+=new_node->score[i];
                    if (new_node->score[i]<60)
                           new_node->gpa[i] = 0;
    
                    else
                           new_node->gpa[i] = new_node->score[i]/10-5;
    
            }
            new_node->ave = sum/5;
            new_node->sum = sum;
        no = head = read();
        node = head->next;
        while (node!=NULL)
            {
                if (node->num == new_node->num)
                {    new_node->next = node->next;
                    no->next = new_node;
                    free(node);
                    printf("学生信息修改成功!\n");
                    
                }
            node = node->next;
            no = no->next;
            }
        write(head);
        
    }
    
    void print(stu *node)
    {
        while(node!=NULL)
        {
        if(node->num == 0)
        {    node= node->next;
            continue;
        }
        printf(ET);
        node = node->next;
        
        }    
    }
    
    void upst(void)
    {
        printf("\t\t任意键返回.\n");
        getchar();
        getchar();
    }
    
    void sta(void)
    {
        sortsum();
        stu *head,*node,*new_node;
        head = read();
        int a[5]={0};
        node = head->next;
        while (node!=NULL)
        {
            if (node->gpa[0]==0) a[0]++;
            if (node->gpa[1]==0) a[1]++;
            if (node->gpa[2]==0) a[2]++;
            if (node->gpa[3]==0) a[3]++;
            if (node->gpa[4]==0) a[4]++;
            node = node->next;
    
        }
        print(head);
        printf("其中高数挂科%d个.\n英语挂科%d个.\n离散挂科%d个.\n大物挂科%d个.\nC语言挂科%d个.\n",a[0],a[1],a[2],a[3],a[4]);
        node = head->next;
        printf("以下是成绩最高学生的信息:\n");
        printf(PT);
        printf(ET);
    
    }
    
    int repas(void)
    {
        stu *head,*node;
        head = read();
        FILE *fp;
        if ((fp = fopen("pass.txt","w+"))==NULL)
        {
            printf("打开文件失败!\n");
            exit(0);
        }
        node = head->next;
        while(node!=NULL)
        {
            strcpy(node->pass,"000000");
            fprintf(fp,"%ld %s\n",node->num,node->pass);
            node = node->next;
        }
        printf("密码重置成功!\n");
        fclose(fp);
        sleep(1);
        clear();
    }
    
    DI *fr()
    {
        FILE *fp;
        if((fp = fopen("pass.txt","r"))==NULL)
        {
            printf("文件读取失败!\n");
            exit(0);
        }
        DI *head,*node,*new_node;
        head = node = (DI *)malloc(sizeof(DI));
        new_node = (DI *)malloc(sizeof(DI));
        fscanf(fp,"%ld %s",&new_node->num,new_node->pass);
        while (!feof(fp))
        {
            node->next = new_node;
            node = new_node;
            new_node = (DI *)malloc(sizeof(DI));
            fscanf(fp,"\n%ld %s",&new_node->num,new_node->pass);
        }
        node->next = NULL;
        free(new_node);
        fclose(fp);
        return head;
    }
    void fw(DI *head)
    {
        FILE *fp;
            if((fp = fopen("pass.txt","w+"))==NULL)
            {
                    printf("文件读取失败!\n");
                    exit(0);
            }
    
        DI *node;
        node = head->next;
        while(node!=NULL)
        {
            fprintf(fp,"%ld %s\n",node->num,node->pass);
            node = node->next;
        }
        fclose(fp);
    }
    
    int password()
    {
        DI *head1,*node1;
        long n;
        int i=3;
        char p[15];
        head1 = fr();
        node1 = head1->next;
    while(1)
    {
        printf("\t\t用户名:");
                    scanf("%ld",&n);
                    printf("\n\t\t密码:");system("stty -echo");
                    scanf("%s",p);system("stty echo");
        while(node1!=NULL)
        {
            if (node1->num==n&&strcmp(node1->pass,p)==0)
            {
                while (1)
                {
                studbe(node1->num);
                }
                return 1;
                
            }
            node1 = node1->next;
        
    
        }
            i--;
                    if (i==0)
                            exit(1);
            printf("您还可以输入%d次!\n",i);
            node1 = head1->next;
    
    
    
    }        
    }
    
    void stud(long num)
    {
        stu *head,*node;
        int i=1,j,lo=0;
        sortsum();
        head = read();
        node = head->next;
        while(node->num!=num)
        {    i++;
            node = node->next;
        }
        for (j=0;j<5;j++)
        {
            if(node->gpa[j]==0)
                lo++;
        }
        printf("PT");
        printf(ET);
        printf("您的成绩在整个年级排第%d位.\n有挂科%d门.\n",i,lo);
    }
    
    int password1()
    {
        char pass[20],pas[20];
        int i=3;
        clear();
        FILE *fp;
        if((fp = fopen("pass","r"))==NULL)
            {
                    printf("文件读取失败!\n");
                    exit(0);
            }
        fscanf(fp,"%s",pas);
        while(1)
        {    printf("\t\t账号:admin");
                printf("\t\t密码:");system("stty -echo");
                scanf("%s",pass);system("stty echo");
            if(strcmp(pas,pass)==0)
            {    while (1)
                    begin();
                    return 1;
            }
            i--;
            if (i==0)
                exit(0);
            printf("您还有%d次输入机会!\n",i);
    
        }
        
    
        
    
    }
    
    void pas(long num)
    {
        clear();
        char a[20],b[20],c[20];
        DI *head,*node;
        head = fr();
        printf("\t\t输入原始密码:");system("stty -echo");
        scanf("%s",a);system("stty echo");
        printf("\n\t\t输入新密码:");system("stty -echo");
        scanf("%s",b);system("stty echo");
            printf("\n\t\t再次输入新密码:");system("stty -echo");
        scanf("%s",c);system("stty echo");
        node = head->next;
        while(node!=NULL)
        {
            if (node->num==num)
                {if (strcmp(node->pass,a)==0&&strcmp(b,c)==0)
                {    strcpy(node->pass,b);
                    fw(head);
                    printf("密码修改成功!\n");
                    break;
                }
                else printf("原密码输入错误或两次新密码不一致,请重试!\n");}
            node = node->next;
            
        }    
    }
    
    studbe(long num)
    {
    clear();
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t*******************************************************************************************************\t\t\n");
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t========|||       **    **               *************                   *         *****    |||========\t\t\n");
    printf("\t\t\t========|||    **************                *   *                       *         *  *     |||========\t\t\n");
    printf("\t\t\t========|||   ****************           *************             * * * * * * *   * *      |||========\t\t\n");
    printf("\t\t\t========|||    **************            *   *   *   *             *     *     *   *  *     |||========\t\t\n");
    printf("\t\t\t========|||      **********              * * *   * * *             * * * * * * *   * **     |||========\t\t\n");
    printf("\t\t\t========|||        ******                *           *             *     *     *   *        |||========\t\t\n");
    printf("\t\t\t========|||          **                  * * * * * * *             * * * * * * *   *        |||========\t\t\n");
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t******************************====================================*************************************\t\t\n");
    printf("\t\t\t===========================|||欢迎来到西安邮电大学学生信息查询系统|||==================================\t\t\n");
    printf("\t\t\t===========================|||              请选择                |||==================================\t\t\n");
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t                           ||| 1.查询自己的信息.                |||\n");
    printf("\t\t\t                           ||| 2.修改密码.                      |||\n");
    printf("\t\t\t                           ||| 0.退出.                          |||\n");
    printf("\t\t\t                           ========================================\n");
    int i;
    printf("\n\t\t\t");
    scanf("%d",&i);
    switch(i)
            {
                    case 1 : clear();stud(num);upst();break;
                    case 2 : clear();pas(num);upst();break;
            case 0 : printf("\t\t\t谢谢使用,再见!\n");system("sl");clear();exit(0);
        }
    }
    
    void admin(void)
    {
    
            clear();
            char a[20],b[20],c[20],d[20];
        FILE *fp;
         if ((fp = fopen("pass","r"))==NULL)
            {
                    printf("打开文件失败!\n");
                    exit(0);
            }
        fscanf(fp,"%s",d);
        fclose(fp);
            printf("\t\t输入原始密码:");system("stty -echo");
            scanf("%s",a);system("stty echo");
            printf("\n\t\t输入新密码:");system("stty -echo");
            scanf("%s",b);system("stty echo");
            printf("\n\t\t再次输入新密码:");system("stty -echo");
            scanf("%s",c);system("stty echo");
                            if (strcmp(d,a)==0&&strcmp(b,c)==0)
                                {
                    fp = fopen("pass","w+");
                                    fprintf(fp,"%s",c);
                                    printf("密码修改成功!\n");
                                }
                            else printf("原密码输入错误或两次新密码不一致,请重试!\n");
        fclose(fp);
            
    
    
    }
    
    int pa(void)
    {
    char pass[20],pas[20];
            int i=3;
    
    FILE *fp;
            if((fp = fopen("pass","r"))==NULL)
            {
                    printf("文件读取失败!\n");
                    exit(0);
            }
            fscanf(fp,"%s",pas);
            while(1)
            {       printf("\t\t账号:admin");
                    printf("\t\t密码:");system("stty -echo");
                    scanf("%s",pass);system("stty echo");
                    if(strcmp(pas,pass)==0)
                    {    
                                    creat();
                                    return 1;
                    }
                    i--;
                    if (i==0)
                            exit(0);
                    printf("您还有%d次输入机会!\n",i);
    }    
    }
    
    void repass()
    {
        clear();
        int i;
        printf("\t\t1.更改管理员密码\n\t\t2.重置学生登录密码(慎重).\n\t\t3.删除所有学生信息并重新创建(慎重)\n\t\t0.返回上一层\n\t\t");
        scanf("%d",&i);
        switch(i)
            {
                    case 1 : clear();admin();upst();break;
                    case 2 : clear();repas();upst();break;
            case 3 : clear();pa();break;
                    case 0 : begin();break;
            }
    
    
    }
    
    begin()
    {
    stu *head,node,new_node;
    clear();
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t*******************************************************************************************************\t\t\n");
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t========|||       **    **               *************                   *         *****    |||========\t\t\n");
    printf("\t\t\t========|||    **************                *   *                       *         *  *     |||========\t\t\n");
    printf("\t\t\t========|||   ****************           *************             * * * * * * *   * *      |||========\t\t\n");
    printf("\t\t\t========|||    **************            *   *   *   *             *     *     *   *  *     |||========\t\t\n");
    printf("\t\t\t========|||      **********              * * *   * * *             * * * * * * *   * **     |||========\t\t\n");
    printf("\t\t\t========|||        ******                *           *             *     *     *   *        |||========\t\t\n");
    printf("\t\t\t========|||          **                  * * * * * * *             * * * * * * *   *        |||========\t\t\n");
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t******************************====================================*************************************\t\t\n");
    printf("\t\t\t===========================|||欢迎来到西安邮电大学学生信息管理系统|||==================================\t\t\n");
    printf("\t\t\t===========================|||              请选择                |||==================================\t\t\n");
    printf("\t\t\t=======================================================================================================\t\t\n");
    printf("\t\t\t                           ||| 1.预览所有学生信息.                |||\n");
    printf("\t\t\t                           ||| 2.查找学生信息.                    |||\n");
    printf("\t\t\t                           ||| 3.添加学生信息.                    |||\n");
    printf("\t\t\t                           ||| 4.删除学生信息.                    |||\n");
    printf("\t\t\t                           ||| 5.修改学生信息.                    |||\n");
    printf("\t\t\t                           ||| 6.统计学生信息.                    |||\n");
    printf("\t\t\t                           ||| 7.重置.                            |||\n");
    printf("\t\t\t                           ||| 0.退出程序                         |||\n");
    printf("\t\t\t                           ==========================================\n");
    int i;
    printf("\t\t\t");
    scanf("%d",&i);
    switch(i)
            {
                    case 1 : clear();sortnum();head = read();print(head);upst();break;
                    case 2 : clear();find();upst();break;
                    case 3 : clear();add();upst();break;
                    case 4 : clear();delete();upst();break;
                    case 5 : clear();mod();upst();break;
                    case 6 : clear();sta();upst();break;
                    case 7 : clear();repass();break;
                    case 0 : printf("\t\t\t谢谢使用,再见!\n");system("sl");clear();exit(0);
            }
    
    }
    
    int main(void)
    {
        clear();
            printf("\t\t<选择登陆方式>\n\t\t1.管理员登陆.\n\t\t2.学生登陆.\n\t\t0.退出程序");
        int i;
        printf("\t\t\t");
        scanf("%d",&i);
        switch(i)
            {
                    case 1 : clear();password1();break;
                    case 2 : clear();password();break;
            case 0 : printf("谢谢使用!\n");sleep(3);exit(0);
        }
    }
    
    
    
    展开全文
  • 环境:linux VI环境 采用双向链表实现多角色(管理员,教师,学生)对学生,教师信息的修改 数据库:文件
  • 这是一款可以在CentOS Linux系统里面运行的使用gtk开发的有简易数据库的学生成绩管理系统,可以实现导入学生信息、修改学生成绩、删除学生信息、查看奖学金获奖名单、查看未挂科学生信息、查看挂科学生信息、按学号...
  • Linux学生信息管理系统设计报告.doc
  • 学生信息管理系统Linux
  • 学生管理系统

    2019-02-12 22:09:31
    建立一个学生的链表,利用链表的增删改查来实现对学生信息的增删改查。
  • Linux下基于shell脚本实现学生信息管理系统

    千次阅读 多人点赞 2019-11-21 15:15:57
    学生管理系统 #!/bin/bash #设置全局变量 ##学生信息和学院信息 #学院相关变量 school_num="" school_name="" #学生相关变量 stu_num="" stu_name="" stu_des="" #成绩相关变量 course="" score="" score_des="" #...

    学生管理系统

    #!/bin/bash
    #设置全局变量
    ##学生信息和学院信息
    #学院相关变量
    school_num=""
    school_name=""
    #学生相关变量
    stu_num=""
    stu_name=""
    stu_des=""
    #成绩相关变量
    course=""
    score=""
    score_des=""
    #用户账户信息
    user_name=""
    user_passwd=""
    ##数据文件存放路径
    source_dir="./source"
    schools_db="./source/schools.db"
    students_db="./source/students.db"
    scores_db="./source/scores.db"
    user_db="./source/user.db"
    #创建数据文件
    mkdir_sourcedir(){
    if [ ! -d $source_dir ];then
    mkdir -p $source_dir
    fi
    if [ ! -f $schools_db ];then
    touch $schools_db
    fi
    if [ ! -f $students_db ];then
    touch $students_db
    fi
    if [ ! -f $scores_db ];then
    touch $scores_db
    fi
    if [ ! -f $user_db ];then
    touch $user_db
    fi
    }
    create_user(){
    read -p "请输入你的用户名:" user_name
    cat file | grep $user_name &>/dev/null
    [ $? -eq 0 ] && echo "这个用户已经存在,请重新创建!" && create_user
    if [ -z $user_name ];then
    echo "该用户可创建" && create_user
    fi
    read -p "请输入密码:" user_passwd
    read -p "请再次输入密码:" passwd1
    if [[ "$user_passwd" != "$passwd1" ]] ;then
    echo "密码验证不正确,请重新创建" && create_user
    fi
    if [ ! -z "$user_passwd" ];then
    echo "$user_name "$user_passwd" " >>file
    echo "创建成功!,按任意键将跳转到登录界面..."
    fi
    if [ -z "$user_passwd" ];then
    echo "$user_name " " " >>file
    echo "创建成功!,按任意键将跳转到登录界面..."
    fi
    clear
    read choice
    case $choice in
    *)
    login
    ;;
    esac
    }
    login(){
    read -p "请输入用户名:" user_name
    a="`cat file | awk '$1=="'$user_name'"'|cut -d ' ' -f2-`"
    b=`echo "$a" | sed 's/ //g'`
    cat file | awk '$1=="'$user_name'"' &> /dev/null
    if [ $? -eq 0 ];then
    read -p "请输入你的密码:" user_passwd
    c=`echo $user_passwd | sed 's/ //g'`
    if [[ "$b" = "$c" ]];then
    echo "登录成功!"
    else
    echo "密码验证不正确,请选择 1. 重新创建 2. 重新登录 3. 退出系统"
    clear
    read choice
    case $choice in
    1)
    create_user
    ;;
    2)
    login
    ;;
    3)
    exit 0
    ;;
    esac
    fi 
    else
    echo "该用户不存在,请选择 1. 重新创建 2. 重新登录 3. 退出系统"
    #create_user
    clear
    read choice
    case $choice in
    1)
    create_user
    ;;
    2)
    login
    ;;
    3)
    exit 0
    ;;
    esac
    fi
    Welcome 
    }
    haha(){
    case $main in
    1)
    create_user
    ;;
    2)
    login
    ;;
    3)
    exit 0
    ;;
    esac
    }
    cat << EOF
    ************请选择:**************
    1) 创建用户
    2) 直接登录
    3) 退出
    EOF
    read -p "Choice:" main
    # 主函数
    Welcome() 
    {
    # reset
    mkdir_sourcedir #数据文件不存在则创建
    echo -e "\t\t\t--------------------------"
    echo -e "\t\t\t 欢迎进入学生管理系统"
    echo -e "\t\t\t--------------------------"
    echo -e "\t\t\t 按任意键继续……"
    read choice
    case $choice in
    *)
    Module
    ;;
    esac
    }
    #模块选择
    Module(){
    clear
    echo -e "\t\t\t**********************"
    echo -e "\t\t\t请输入对应数字选择信息模块"
    echo -e "\t\t\t 1. 学院信息管理"
    echo -e "\t\t\t 2. 学生信息管理"
    echo -e "\t\t\t 3. 成绩信息管理"
    echo -e "\t\t\t 4. 退出系统"
    read choice
    case $choice in
    1)
    Menu1
    ;;
    2)
    Menu2
    ;;
    3)
    Menu3
    ;;
    4)
    exit 0
    ;;
    *)
    Module
    ;;
    esac
    }
    ###############
    #学院信息模块功能实现
    ###############
    #学院信息模块菜单
    Menu1(){
    clear
    echo -e "\t\t\t****************************"
    echo -e "\t\t\t请输入对应数字选择功能"
    echo -e "\t\t\t 1. 添加学院"
    echo -e "\t\t\t 2. 删除学院"
    echo -e "\t\t\t 3. 学院列表"
    echo -e "\t\t\t 4. 查找学院"
    echo -e "\t\t\t 5. 修改学院"
    echo -e "\t\t\t 6. 返回上级"
    echo -e "\t\t\t 7. 退出系统"
    echo -e "\t\t\t****************************"
    echo "请选择:"
    read choice
    case $choice in
    1)
    echo -e "\t\t\t添加学院"
    add_school
    ;;
    2)
    echo -e "\t\t\t删除学院"
    del_school
    ;;
    3)
    echo -e "\t\t\t学院列表"
    display_schools
    ;;
    4)
    echo -e "\t\t\t查找学院"
    find_school
    ;;
    5)
    echo -e "\t\t\t修改学院"
    update_school
    ;;
    6)
    echo -e "\t\t\t返回上级"
    Module
    ;;
    7) 
    exit 0
    ;;
    *)
    Menu1
    ;;
    esac
    echo "--------------------------"
    echo "按任意键继续……"
    read c	
    Menu1
    }
    #1.添加学院信息
    add_school(){
    read -p "school_num:" school_num
    #防止输入空格
    while [ "$school_num" = '' ];do
    read -p "输入的学院编号不能为空,请重新输入学院编号:" school_num
    done
    while grep -w "$school_num" "$schools_db" > /dev/null ;do 
    echo "已经存在该编号的学院了,请改用其他编号!"
    read -p "school_num:" school_num
    done
    read -p "school_name:" school_name
    #防止输入空格
    while [ "$school_name" = '' ];do
    read -p "输入的学院名称不能为空,请重新输入学院名称:" school_name
    done
    echo -e "$school_num,\t$school_name,\r" >> $schools_db
    }
    #2.删除学院
    del_school(){
    read -p "请输入学院的编号" school_num
    while ! grep -w "$school_num" "$schools_db" > /dev/null ; do
    echo "不存在该编号的学校,请输入编号存在的学校编号: "
    read -p "school_num:" school_num
    done
    echo "该学院的信息为:"
    grep "^$school_num" $schools_db
    read -p "确定删除吗?[yes|no]" choice
    case "$choice" in
    yes)
    sed -i -e "/^$school_num/d" $schools_db
    if [ "$?" -eq 0 ];then
    echo "删除成功"
    else
    echo "不存在该条记录或者删除失败"
    fi
    ;;
    no)	
    :
    ;;
    *)
    echo "请输入[yes|no]"
    del_school
    ;;
    esac
    }
    #3.展示全部学院信息
    display_schools(){
    echo -e "编号\t学院\t"
    cat $schools_db
    }
    #4.查找学院
    find_school(){
    echo "--------------------------"
    echo "输入要查询的学院编号"
    read school_num
    echo "--------------------------"
    echo -e "编号\t学院\t"
    grep -w $school_num $schools_db #-w只显示全字符合的列
    echo "--------------------------"
    echo "查询成功"
    }
    #5.修改学院信息
    update_school(){
    echo "--------------------------"
    read -p "输入学院编号:" school_num
    #防止输入空格
    while [ "$school_num" = '' ];do
    read -p "输入有误,请重新。输入学院编号:" school_num
    done
    while ! grep -w "$school_num" "$schools_db" > /dev/null ; do
    echo "不存在该编号的学校,请输入编号存在的学校编号: "
    read -p "school_num:" school_num
    #防止输入空格
    while [ "$school_num" = '' ];do
    read -p "输入有误,请重新。输入学院编号:" school_num
    done
    done
    echo "--------------------------"
    echo -e "编号\t学院\t"
    grep -w $school_num $schools_db
    echo "--------------------------"
    read -p "要修改的字段信息" str1
    #防止输入空格
    while [ "$str1" = '' ];do
    read -p "输入有误,请重新。要修改的字段信息:" str1
    done
    while ! grep -w "$school_num,.*," "$schools_db"|grep -w "$str1"> /dev/null;do
    echo "不存在该字段,请重新输入:"
    read str1
    #防止输入空格
    while [ "$str1" = '' ];do
    read -p "输入有误,请重新。要修改的字段信息:" str1
    done
    done
    read -p "修改后的字段信息" str2
    #防止输入空格
    while [ "$str2" = '' ];do
    read -p "输入有误,请重新。修改后的字段信息:" str2
    done
    read -p "确定删除吗?[yes|no]" choice
    case "$choice" in
    yes)
    sed -i "/${school_num#,}/ s/$str1/$str2/" $schools_db
    if [ "$?" -eq 0 ];then
    echo "修改成功"
    echo "--------------------------"
    echo "修改后的学院信息"
    echo -e "编号\t学院\t"
    cat $schools_db
    if [ "$str1" = "$school_num" ];then #如果修改的是学院编号还要修改学生表里的学院编号
    sed -i "/${school_num#,}/ s/$str1/$str2/" $students_db
    fi
    else
    echo "修改失败"
    fi
    ;;
    no)	
    :
    ;;
    *)
    echo "请输入[yes|no]"
    del_student
    ;;
    esac
    }
    ###################
    #学生信息模块功能实现
    ###################
    #学生信息模块菜单
    Menu2() {
    clear
    echo -e "\t\t\t**********************"
    echo -e "\t\t\t请输入对应数字选择功能"
    echo -e "\t\t\t 1. 添加学生"
    echo -e "\t\t\t 2. 删除学生"
    echo -e "\t\t\t 3. 学生列表"
    echo -e "\t\t\t 4. 查找学生"
    echo -e "\t\t\t 5. 修改学生"
    echo -e "\t\t\t 6. 返回上级"
    echo -e "\t\t\t 7. 退出系统"
    echo -e "\t\t\t**********************"
    echo "请选择:"
    read choice
    case $choice in
    1)
    echo -e "\t\t\t添加学生信息"	
    add_student
    ;;
    2)
    echo -e "\t\t\t删除学生信息"
    del_student
    ;;
    3) 
    echo -e "\t\t\t展示学生信息"
    display_students
    ;;
    4)
    echo -e "\t\t\t搜索学生信息"
    search_student_num
    ;;
    5)
    echo -e "\t\t\t修改学生信息"
    modify_student
    ;;
    6)
    echo -e "\t\t\t返回上一个页面"
    Module
    ;;
    7) 
    exit 0
    ;;
    *)
    Menu2
    ;;
    esac
    echo "--------------------------"
    echo "按任意键继续……"
    read c
    Menu2
    }
    #1.添加学生信息
    add_student(){
    read -p "stu_num:" stu_num
    while grep -w "$stu_num" "$students_db" > /dev/null ;do 
    echo "已经存在该学号的学生了,请改用其他学号!"
    read -p "stu_num:" stu_num
    done	
    read -p "stu_name:" stu_name
    read -p "school_num:" school_num
    #将结果丢失,不显示在屏幕中
    while ! grep -w "$school_num" "$schools_db" > /dev/null ; do
    echo "不存在该编号的学校,请输入编号存在的学校编号: "
    read -p "school_num:" school_num
    done
    read -p "stu_des:" stu_des
    echo -e "$stu_num,\t$stu_name,\t$school_num,\t$stu_des,\r" >> $students_db
    echo "成功添加学生信息,添加的信息为: "
    grep -w $stu_num $students_db
    }
    #2.删除学生
    del_student(){
    read -p "请输入要删除的学生的学号" num
    echo "该学生的信息为:"
    grep "^$num" $students_db
    read -p "确定删除吗?[yes|no]" choice
    case "$choice" in
    yes)
    sed -i -e "/^$num/d" $students_db
    if [ "$?" -eq 0 ];then
    echo "删除成功"
    else
    echo "不存在该条记录或者删除失败"
    fi
    ;;
    no)	
    :
    ;;
    *)
    echo "请输入[yes|no]"
    del_student
    ;;
    esac
    }
    #3.显示所有学生信息 
    display_students() {
    echo "--------------------------"
    echo -e "学号\t姓名\t学院\t说明"
    sed -n '1,$p' $students_db
    echo "--------------------------"
    echo -e "\r"
    }
    #4.查询学生信息 
    search_student_num() {
    echo "--------------------------"
    echo "输入要查询的学号"
    read num
    echo "--------------------------"
    echo -e "学号\t姓名\t学院\t说明"
    grep -w $num $students_db
    # grep -w "${num#*,}" $students_db
    echo "--------------------------"
    echo "查询成功"
    }
    #5.修改学生信息
    modify_student() {
    echo "--------------------------"
    echo "输入学生所在的学院:"
    read school_num
    #防止输入空格
    while [ "$school_num" = '' ];do
    read -p "输入有误,请重新。输入学生所在的学院:" school_num
    done
    while ! grep -w "$school_num" "$schools_db" > /dev/null;do
    echo "不存在该编号的学院,请重新输入:"
    read school_num
    #防止输入空格
    while [ "$school_num" = '' ];do
    read -p "输入有误,请重新。输入学生所在的学院:" school_num
    done
    done
    echo "输入要查询的学号:"
    read num
    #防止输入空格
    while [ "$num" = '' ];do
    read -p "输入有误,请重新。输入要查询的学号:" num
    done
    while ! grep -w "$num,.*,.*,.*," "$students_db" > /dev/null;do
    echo "不存在该编号的学生,请重新输入:"
    read num
    #防止输入空格
    while [ "$num" = '' ];do
    read -p "输入有误,请重新。输入要查询的学号:" num
    done
    done
    echo "--------------------------"
    echo -e "学号\t姓名\t学院\t说明"
    grep "${num#,}" $students_db
    echo "--------------------------"
    echo "要修改的字段信息"
    read str1
    #防止输入空格
    while [ "$str1" = '' ];do
    read -p "输入有误,请重新。要修改的字段信息:" str1
    done
    while ! grep -w "$num,.*,.*,.*," "$students_db"|grep -w "$str1"> /dev/null;do
    echo "不存在该字段,请重新输入:"
    read str1
    #防止输入空格
    while [ "$str1" = '' ];do
    read -p "输入有误,请重新。要修改的字段信息:" str1
    done
    done
    echo "修改后的字段信息"
    read str2
    #防止输入空格
    while [ "$str2" = '' ];do
    read -p "输入有误,请重新。修改后的字段信息:" str2
    done
    if [ "$str1" = "$school_num" ];then
    while ! grep -w "$str2" "$schools_db" > /dev/null;do
    echo "不存在该编号的学院,请重新输入:"
    read str2
    #防止输入空格
    while [ "$str2" = '' ];do
    read -p "输入有误,请重新。修改后的字段信息:" str2
    done
    done
    fi
    read -p "确定删除吗?[yes|no]" choice
    case "$choice" in
    yes)
    #如果修改的是学生编号还要修改成绩表里的学生编号
    if [ "$str1" = "$num" ];then 
    sed -i "/${num#,}/ s/$str1/$str2/" $scores_db
    fi
    #如果修改的是学生姓名还要修改成绩表里的学生姓名
    studentName=$(grep "^$num," "$students_db"|sed -n "1p"|cut -d "," -f 2|cut -f 2) #获取学生的姓名,最后一个cut作用是去除字符串前的制表符
    if [ "$str1" = "$studentName" ];then
    sed -i "/^$num,/ s/$studentName/$str2/" "$scores_db" #根据学号来修改成绩表姓名的信息
    fi
    #修改学生表
    sed -i "/${num#,}/ s/$str1/$str2/" $students_db
    if [ "$?" -eq 0 ];then
    echo "------------修改成功--------------"
    echo "修改后的学生信息"
    echo -e "学号\t姓名\t学院\t说明"
    grep "${num#,}" $students_db | grep "$str2"
    else
    echo "修改失败"
    fi
    ;;
    no)	
    :
    ;;
    *)
    echo "请输入[yes|no]"
    modify_student
    ;;
    esac
    }
    ###################
    #成绩信息模块功能实现
    ###################
    #成绩信息模块菜单
    Menu3() {
    clear
    echo -e "\t\t\t**********************"
    echo -e "\t\t\t请输入对应数字选择功能"
    echo -e "\t\t\t 1. 添加成绩"
    echo -e "\t\t\t 2. 删除成绩"
    echo -e "\t\t\t 3. 成绩列表"
    echo -e "\t\t\t 4. 查找成绩"
    echo -e "\t\t\t 5. 修改成绩"
    echo -e "\t\t\t 6. 成绩统计"
    echo -e "\t\t\t 7. 返回上级"
    echo -e "\t\t\t 8. 退出系统"
    echo -e "\t\t\t**********************"
    echo "请选择:"
    read choice
    case $choice in
    1)
    echo -e "\t\t\t添加成绩"	
    add_score
    ;;
    2)
    echo -e "\t\t\t删除成绩"
    del_score
    ;;
    3) 
    echo -e "\t\t\t展示成绩信息"
    display_scores
    ;;
    4)
    echo -e "\t\t\t搜索成绩信息"
    search_score_num
    ;;
    5)
    echo -e "\t\t\t修改成绩信息"
    modify_score
    ;;
    6)
    echo -e "\t\t\t成绩统计"
    score_count
    ;;
    7)
    echo -e "\t\t\t返回上一个页面"
    Module
    ;;
    8) 
    exit 0
    ;;
    *)
    Menu3
    ;;
    esac
    echo "--------------------------"
    echo "按任意键继续……"
    read c	
    Menu3
    }
    #成绩统计模块
    score_count(){
    clear
    echo -e "\t\t\t**********************"
    echo -e "\t\t\t请输入对应数字选择功能"
    echo -e "\t\t\t 1. 每学科的前3名"
    echo -e "\t\t\t 2. 个人总成绩前5名"
    echo -e "\t\t\t 3. 返回上一级"
    echo -e "\t\t\t 4. 退出系统"
    echo -e "\t\t\t**********************"
    echo "请选择:"
    read choice
    case $choice in
    1)
    echo -e "\t\t\t每学科的前3名"	
    such_course_sort_score
    ;;
    2)
    echo -e "\t\t\t个人总成绩前5名"
    sort_score_sum_five
    ;;
    3)
    Menu3
    ;;
    4) 
    exit 0
    ;;
    *)
    score_count
    ;;
    esac
    echo "--------------------------"
    echo "按任意键继续……"
    read c	
    score_count
    }
    #1.添加成绩
    input_score_info(){ #成绩信息输入
    read -p "stu_num:" stu_num
    while ! grep -w "$stu_num" "$students_db" > /dev/null ;do 
    echo "此学号没有录入在系统中,请重新输入正确的学号!"
    read -p "stu_num:" stu_num
    done
    read -p "stu_name:" stu_name
    while ! grep -w "$stu_name" "$students_db" > /dev/null ;do 
    echo "名字和学号不对应,请重新输入"
    read -p "stu_name:" stu_name
    done
    read -p "course:" course
    read -p "score:" score
    read -p "score_des:" score_des	
    while grep -w $stu_num $scores_db|grep -w $course > /dev/null ;do #学号和科目确定成绩的唯一性
    echo "该学生的此科目成绩已经录入,请再次输入: "
    input_score_info
    done
    }
    add_score(){ #添加成绩
    input_score_info	
    echo -e "$stu_num,\t$stu_name,\t$course,\t$score,\t$score_des,\r" >> $scores_db
    echo "成功添加学生成绩信息,添加的信息为: "
    echo -e "学号\t姓名\t科目\t成绩\t说明"
    grep -w $stu_num $scores_db|grep -w $course #学号和科目确定成绩的唯一性
    }
    #2.删除成绩
    del_score(){
    read -p "请输入学生的学号" num
    read -p "请输入该学生要删除的科目" score
    echo "该条成绩信息为:"
    grep "^$num," $scores_db|grep "$score,"
    read -p "确定删除吗?[yes|no]" choice
    case "$choice" in
    yes)
    sed -i -e "/^$num,.*$score,/d" $scores_db
    if [ "$?" -eq 0 ];then
    echo "删除成功"
    else
    echo "不存在该条记录或者删除失败"
    fi
    ;;
    no)	
    :
    ;;
    *)
    echo "请输入[yes|no]"
    del_score
    ;;
    esac
    }
    #3.成绩列表
    display_scores(){
    echo ""
    echo -e "学号\t姓名\t科目\t 成绩 说明"
    cat $scores_db|column -t
    }
    #4.查找成绩
    search_score_num(){
    read -p "输入要查看的学生的学号" num
    read -p "输入要查看的科目" score
    echo -e "学号\t姓名\t科目\t成绩\t说明"
    grep "^$num," $scores_db|grep "$score,"
    }
    #5.修改成绩
    modify_score() {
    echo "--------------------------"
    read -p "输入学号(不能有空格):" num
    while ! grep "^$num," "$scores_db" > /dev/null;do
    echo "不存在该编号的学生,请重新输入:"
    read num
    done
    #防止输入空格
    while [ "$num" = '' ];do #num=$(printf "$num"|sed s/[[:space:]]//g)
    echo "输入有误,请重新:"
    read -p "输入学号(不能有空格):" num
    done
    read -p "输入科目:" course
    #防止输入空格
    while [ "$course" = '' ];do
    echo "输入有误,请重新:"
    read -p "输入科目:" course
    done
    while ! grep "^$num,.*$course," "$scores_db" > /dev/null;do
    echo "成绩表里不存在该编号的学生,请重新输入:"
    read course
    #防止输入空格
    while [ "$course" = '' ];do
    echo "输入有误,请重新:"
    read -p "输入科目:" course
    done
    done
    echo "--------------------------"
    echo -e "学号\t姓名\t科目\t成绩\t说明"
    grep "^$num," "$scores_db"|grep "$course," #学号和科目确定成绩的唯一性
    echo "--------------------------"
    read -p "要修改的字段信息:" str1
    #防止输入空格
    while [ "$str1" = '' ];do
    echo "输入有误,请重新:"
    read -p "要修改的字段信息:" str1
    done
    while [ "$str1" = "$num" ];do
    echo "请输入其他字段(成绩表里不能瞎改学号,如果非要改,请修改学生表:)"
    read str1
    #防止输入空格
    while [ "$str1" = '' ];do
    echo "输入有误,请重新:"
    read -p "要修改的字段信息:" str1
    done
    done
    scores_db_studentName=$(grep "^$num," "$scores_db"|sed -n "1p"|cut -d "," -f 2|cut -f 2) #从成绩表里获取学生姓名
    while [ "$str1" = "$scores_db_studentName" ];do
    echo "请输入其他字段(成绩表里不能瞎改姓名,如果非要改,请修改学生表:)"
    read str1
    #防止输入空格
    while [ "$str1" = '' ];do
    echo "输入有误,请重新:"
    read -p "要修改的字段信息:" str1
    done
    done
    while ! grep "^$num,.*$course," "$scores_db"|grep "$str1,"> /dev/null;do
    echo "不存在该字段,请重新输入:"
    read str1
    #防止输入空格
    while [ "$str1" = '' ];do
    echo "输入有误,请重新:"
    read -p "要修改的字段信息:" str1
    done
    done
    read -p "修改后的字段信息:" str2
    #防止输入空格
    while [ "$str2" = '' ];do
    echo "输入有误,请重新:"
    read -p "修改后的字段信息:" str2
    done
    read -p "确定删除吗?[yes|no]" choice
    case "$choice" in
    yes)
    sed -i "/^$num,.*$course,/ s/$str1/$str2/" $scores_db
    if [ "$?" -eq 0 ];then
    echo "------------修改成功--------------"
    echo "修改了的信息"
    echo -e "学号\t姓名\t科目\t成绩\t说明"
    grep "^$num,.*$course," "$scores_db" #学号和科目确定成绩的唯一性
    echo "--------------------------"
    else
    echo "修改失败"
    fi
    ;;
    no)	
    :
    ;;
    *)
    echo "请输入[yes|no]"
    modify_score
    ;;
    esac
    }
    #6.个人总成绩前5名排序
    sort_score_sum_five(){
    echo "-----------总成绩前1到5名---------------"
    printf "学号\t\t总成绩\t排名\t\n";
    awk -F"," '{ary[$1]+=$4} END{for(key in ary) print key ",\t" ary[key]",\t"}' $scores_db|sort -r -n -t',' -k 2| awk -F"," '{print $1 ",\t" $2",\t" NR ",\t"}'|sed -n '1,5p'
    echo "--------------------------"
    }
    #7.每个学科的前3名
    such_course_sort_score(){
    awk 'BEGIN{FS=","}{ary[$3]=$3} END{for(key in ary) print ary[key]}' $scores_db > temp
    size=$(cat temp|wc -l)
    top=1
    while [ "$top" -le "$size" ];do
    var=$(sed -n "$top p" temp)
    grep "$var," $scores_db |sort -r -n -t "," -k 4 |sed -n '1,3p'|awk 'BEGIN{FS="," ; printf "科目\t学号\t姓名\t排名\t\n"}{printf $3 "\t" $1 "\t" $2 "\t" NR "\t\n"}'|column -t
    echo ""
    top=$(($top+1))
    done
    rm -rf temp
    }
    
    展开全文
  • 早期写的在linux下编写的C程序,作为巩固C语言的实践项目。
  • Qt学生信息管理系统

    2018-04-20 10:39:04
    附带源码和作者联系方式 ,非常适合初学者参考学习
  • 为了解决学生信息管理系统的安全,确保系统当中的数据的完整性和安全性,从网络方面、服务器采用的操作系统方面以及数据库安全等方面进行了设计。在该系统在操作系统方面采用了安全性较为高的Linux和数据库安全性...
  • 学生信息管理系统 表: 学生信息表 入学的时候 --学号[主关键字] 姓名 性别 班级 籍贯 考试成绩表 考试的时候生产的 --学号[] 姓名 成绩 班级 教师表 老师 --名字 工号 教龄 班级 功能: 学生信息...
  • 这是一个用python 写的学生系统管理的程序,可以实现对学生信息的增删改查.是python 基础入门学习的一个很有用的代码.
  • 用链表和C语言在Linux下实现简单学生管理系统
  • 学生基本信息管理系统(LINUX下).doc

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 31,436
精华内容 12,574
关键字:

linux学生信息管理系统