12作业
#include<stdio.h> #include<stdib.h> struct student { char number[10]; char name[20]; char age; char gender; char phone[11]; char dept[20]; char score; }; int main() { return 0; }
#include<stdio.h> struct student { char sno[10]; char sname[20]; int age; }; int main() { student class3[31]; FILE *fp=fopen("e:\\input.txt","r"); fscanf(fp,"%s%s%d",class3[0].sno,class3[0].sname,&class3[0].age); fclose(fp); fp=fopen("e:\\sanban.txt","m"); printf("%s %s %d",class3[0].sno,class3[0].sname,class3[0].age); fclose(fp); return 0; }
#include<stdio.h> #include<stdlib.h> struct student { char sno[10]; char sname[20]; int age; }; void addStudent() { student class3; int ch; FILE *fp=fopen("g:\\student.txt","a+"); printf("学号:"); scanf("%s",class3.sno); printf("姓名:"); scanf("%s",class3.sname); printf("年龄:"); scanf("%d",&class3.age); printf("%s %s %d\n",class3.sno,class3.sname,class3.age); printf("信息添加成功,是否继续添加学生信息(Y/N)"); scanf("%s",&ch); do { printf("学号:"); scanf("%s",class3.sno); printf("姓名:"); scanf("%s",class3.sname); printf("年龄:"); scanf("%d",&class3.age); printf("%s %s %d\n",class3.sno,class3.sname,class3.age); printf("信息添加成功,是否继续添加学生信息(Y/N)"); scanf("%s",&ch); } while(ch=='y' || ch=='Y'); int main() { int i; if(a==1) { printf("学生信息管理系统\n"); printf("1.添加学生信息\n"); printf("请选择:\n"); scanf("%d",&i); } return 0;
}