zoukankan      html  css  js  c++  java
  • C语言学生信息管理系统

    //原创,,,!! 账号:admin ; 密码:123456;

    //输入信息时按照 fengshun 1403 m 311409010315 99 98 97格式输入, 输出会比较整齐 ;

      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include <algorithm>
      5 using namespace std;
      6 int n;
      7 
      8 struct student
      9 {
     10     char name[20] ;          //姓名 ; 
     11     char classnumber[10] ;   //班级 ;(1403) 
     12     char gender[2] ;         //性别 ; 
     13     char xuehao[20] ;        //学号 ; 
     14     int math ;               //数学成绩 ; 
     15     int chinese ;            //语文成绩 ; 
     16     int computer ;           //计算机成绩 ; 
     17 } ;
     18 student num[10] ;
     19 
     20 bool cmp(student xuehao,student classnumber)
     21 {
     22     return strcmp(xuehao.name, classnumber.name) < 0 ;
     23 }
     24 
     25 void SCANF(int n)            //学生信息输入 ;  
     26 {
     27     int i ;
     28     for(i=1; i<=n; i++)
     29     {
     30         printf("请输入第%d个学生信息:
    ",i) ;
     31         scanf("%s %s %s %s %d %d %d",num[i].name, num[i].classnumber, num[i].gender, num[i].xuehao, &num[i].math, &num[i].chinese, &num[i].computer) ;
     32     }
     33 }
     34 
     35 void PRINTF(int n)          //输出全部学生信息 ; 
     36 {
     37     int  i;
     38     printf("name     classnumber gender xuehao       math chinese computer
    ") ;
     39     for(i=1; i<=n; i++)
     40     printf("%s %s        %s      %s %d   %d      %d
    ",num[i].name, num[i].classnumber, num[i].gender, num[i].xuehao, num[i].math, num[i].chinese, num[i].computer) ;
     41     printf("
    ") ;
     42 }
     43 
     44 void PAIXU(int n)            //对学生信息按照名字首字母进行排序 ; 
     45 {
     46     sort (num+1, num+n+1, cmp) ;
     47 }
     48 
     49 void SINGLEPRINTF(int temp)  //查询某个学生信息 ; 
     50 {
     51     printf("%s %s %s %s %d %d %d
    ",num[temp].name, num[temp].classnumber, num[temp].gender, num[temp].xuehao, num[temp].math, num[temp].chinese, num[temp].computer ) ;
     52 }
     53 
     54 
     55 void ALTER(int n)           //修改学生信息 ; 
     56 {
     57     scanf("%s %s %s %s %d %d %d",num[n].name, num[n].classnumber, num[n].gender, num[n].xuehao, &num[n].math, &num[n].chinese, &num[n].computer) ;
     58 } 
     59 
     60 void HEAD ()                // 登录界面 ; 
     61 {
     62     printf("
    
    ");  
     63         printf("  	┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
    ");  
     64         printf("  	┃ ******************************************************** ┃
    ");  
     65         printf("  	┃***┏━━━━━━━━━━━━━━━━━━━━━━━━┓***┃
    ");  
     66         printf("  	┃***┃************************************************┃***┃
    ");  
     67         printf("  	┃***┃***                                         ****┃***┃
    ");  
     68         printf("  	┃***┃***         欢迎使用学生信息管理系统        ****┃***┃
    ");  
     69         printf("  	┃***┃***                                         ****┃***┃
    ");  
     70         printf("  	┃***┃***                                         ****┃***┃
    ");  
     71         printf("  	┃***┃***                  封顺                   ****┃***┃
    ");  
     72         printf("  	┃***┃***                                         ****┃***┃
    ");  
     73         printf("  	┃***┃***                2015.07.05               ****┃***┃
    ");  
     74         printf("  	┃***┃***                                         ****┃***┃
    ");  
     75         printf("  	┃***┃************************************************┃***┃
    ");  
     76         printf("  	┃***┗━━━━━━━━━━━━━━━━━━━━━━━━┛***┃
    ");  
     77         printf("  	┃ ******************************************************** ┃
    ");  
     78         printf("  	┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    ");    
     79 } 
     80 
     81 void GONGNENG()   // 功能菜单 ; 
     82 {
     83       printf("
    
    
    ");  
     84         printf("  	┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
    ");  
     85         printf("  	┃ ******************************************************** ┃
    ");  
     86         printf("  	┃***┏━━━━━━━━━━━━━━━━━━━━━━━━┓***┃
    ");  
     87         printf("  	┃***┃************************************************┃***┃
    ");  
     88         printf("  	┃***┃***  1、学生信息输入      2、学生信息查询   ****┃***┃
    ");  
     89         printf("  	┃***┃***                                         ****┃***┃
    ");  
     90         printf("  	┃***┃***                                         ****┃***┃
    ");  
     91         printf("  	┃***┃***  3、输出全部学生信息  4、学生信息排序   ****┃***┃
    ");  
     92         printf("  	┃***┃***                                           ****┃***┃
    ");  
     93         printf("  	┃***┃***                                         ****┃***┃
    ");  
     94         printf("  	┃***┃***  5、学生信息修改      6、退出系统       ****┃***┃
    ");  
     95         printf("  	┃***┃***                                         ****┃***┃
    ");  
     96         printf("  	┃***┃************************************************┃***┃
    ");  
     97         printf("  	┃***┗━━━━━━━━━━━━━━━━━━━━━━━━┛***┃
    ");  
     98         printf("  	┃ ******************************************************** ┃
    ");  
     99         printf("  	┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    ");
    100 }
    101 
    102 main()  
    103 {
    104     int times=3 ;
    105     do
    106     {
    107         int i ; char str[10], ch[10] ;  
    108         HEAD () ; 
    109         printf("                       请输入您的账号:") ;
    110         scanf("%s",str) ;    
    111         printf("                       请输入您的密码:") ;
    112         scanf("%s",ch) ; 
    113         printf("
    ") ;
    114         if(strcmp(str, "admin") == 0 && strcmp(ch, "123456") == 0)
    115         {
    116             system("cls") ;   //清屏函数 ; 
    117             printf("登陆成功,请选择操作:") ; 
    118             GONGNENG () ; 
    119             printf("
    ") ;
    120             int a, temp=0 ;   //temp=0 ; 
    121              do 
    122             {
    123                 printf("
    
    ") ;
    124                 printf("********************请输入学生管理系统功能所对应编号(1~6)*********************") ;
    125                 printf("请输入编号:") ; 
    126                 scanf("%d", &a) ;
    127                 printf("
    ") ;
    128                 switch(a)
    129                 {
    130                     
    131                     int key;  key=0 ;      //设置一个开关key ; 在没有执行系统功能1时提醒先进行学生信息输入 ; 
    132                     case 1:
    133                     {
    134                         system("cls") ;
    135                         key = 1 ;
    136                         printf("统计信息包括:姓名 班级 性别 学号 数学成绩 语文成绩 计算机成绩
    
    ") ; 
    137                         printf("请输入要统计学生信息的总人数:");
    138                         scanf("%d",&n) ; 
    139                         SCANF(n) ;        //调用函数 ; 
    140                         printf("
    ") ;
    141                         system("cls") ;
    142                         printf("********************      输入完毕,请选择下一功能       ********************");
    143                         GONGNENG () ;    //调用函数 ; 
    144                         break;  
    145                     }
    146                     case 2: 
    147                     {
    148                         system("cls") ;
    149                         if(key == 1)
    150                         {
    151                             printf("请输入需要查询学生号码 :") ;
    152                             int temp ;
    153                             scanf("%d",&temp) ;
    154                             SINGLEPRINTF(temp) ;  //调用函数 ; 
    155                             system("pause") ;
    156                             printf("查询完毕,请选择下一功能") ;
    157                             GONGNENG () ;         //调用函数 ; 
    158                         }
    159                         else
    160                         {
    161                             printf("请先执行信息输入操作") ; 
    162                             GONGNENG () ;         //调用函数; 
    163                         }
    164                         break ; 
    165                     }
    166                     case 3:
    167                     {
    168                         system("cls") ;
    169                         if(key == 1)
    170                         {
    171                             printf("将输出所有学生成绩
    ");
    172                             PRINTF(n) ;           //调用函数 ; 
    173                             system ("pause") ;
    174                             printf("查询完毕,请选择下一功能") ;
    175                             GONGNENG () ;         //调用函数 ; 
    176                         }
    177                         else
    178                         {
    179                             printf("请先执行信息输入操作") ;
    180                             GONGNENG () ;         //调用函数 ; 
    181                         }
    182                         break ;
    183                     } 
    184                     case 4: 
    185                     {
    186                         system ("cls") ;
    187                         if(key==1)
    188                         {
    189                             PAIXU(n) ;           //调用函数 ; 
    190                             system("cls") ;
    191                             printf("排序完成,请选择下一功能") ;
    192                             GONGNENG () ;        //调用函数 ; 
    193                         }
    194                         else
    195                         {
    196                             printf("请先执行信息输入操作") ;
    197                             GONGNENG () ;        //调用函数 ; 
    198                         }
    199                         break ;
    200                     }
    201                     case 5:
    202                     {
    203                         system("cls") ;
    204                         if(key == 1)
    205                         {
    206                             int n;  
    207                             printf("请输入要修改第几个学生信息(1~n):") ;  
    208                             scanf("%d",&n) ;
    209                             printf("
    ") ;
    210                             printf("开始修改:
    ") ;
    211                             ALTER(n) ;        //调用函数 ; 
    212                             system("cls") ;                
    213                             printf("修改完毕,请选择下一功能") ;
    214                             GONGNENG () ;    //调用函数 ; 
    215                         }
    216                         else
    217                         {
    218                             printf("请先执行信息输入操作") ;
    219                             GONGNENG () ;    //调用函数 ; 
    220                         }
    221                         break ;
    222                     }
    223                     case 6:
    224                     {
    225                         system ("cls") ;
    226                         printf("很高兴为您服务,您将退出本次登陆
    
    
    ") ;
    227                         temp=1 ;
    228                     }
    229                 }
    230             }
    231             while(!temp) ;
    232         }
    233         else
    234         {
    235             times-- ;
    236             system ("cls") ;
    237             printf("ERROR !! 账号和密码输入错误 !!剩余输入机会:%d",times) ;
    238         }
    239     }
    240     while(times>0) ;
    241 }
  • 相关阅读:
    今天没事做了个MBTI职业倾向测试
    Prototype 源码解读[资源]
    ◎◎identity ,ident_current() ,scope_identity的区别
    进军SharePoint,资料先行....
    这两天写了个分页控件,分享代码
    高效率的object转int的函数
    可填可选的DropDownList Server Control
    [DHTML]setInterval与setTimeout的区别
    提两个建议
    通过XSL template与import实现代码重用
  • 原文地址:https://www.cnblogs.com/soTired/p/4622026.html
Copyright © 2011-2022 走看看