学会一门编程语言不是在于学习了多少语法
而是在于能否将语法混合运用
这个项目十分适合现在拿来练手
这个项目可以查看学生列表
添加学生
退出系统
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include <stdio.h> #include <string.h>
struct list { char name[20]; int age; char information[20]; };
int menu(){ printf("学生管理系统\n"); printf("1.查看学生列表\n"); printf("2.添加学生\n"); printf("3.退出系统\n"); }
int main(){ int a; int b=0; struct list student[60]; while(1){
menu(); scanf("%d",&a); switch (a) { case 1: while() for(int c=0;c<=b;c++){ printf("%d.姓名:%s\n",c,student[c].name); printf("年龄:%d\n",student[c].age); printf("信息:%s\n",student[c].information); } break; case 2: b=b+1; if (b >= 60) { printf("学生已经满了\n"); break; } printf("请输入学生姓名\n"); scanf("%s",student[b].name); printf("请输入学生年龄\n"); scanf("%d",&student[b].age); printf("请输入学生信息\n"); scanf("%s",student[b].information); printf("学生信息已添加完毕"); break; case 3: printf("系统已退出\n"); return 0; default: printf("输入错误,请输入正确的数字\n"); break; } } }
|