首页 > 代码库 > c语言第12次作业

c语言第12次作业

#include<stdio.h>
#include<stdlib.h>
struct student{
    char sno[10];
    char stele[15];
    char sname[20];
    int score;
    int age;
    
};
int main()
{    
    student class3[31];
    scanf("%s%s%s%d%d",&class3[0].sno,&class3[0].sname,&class3[0].stele,&class3[0].age,&class3[0].score);
    printf("%s %s %s %d %d",class3[0].sno,class3[0].sname,class3[0].stele,class3[0].age,class3[0].score);
    return 0;    
}

#include<stdio.h>
struct student
{
char sno[10];
char sname[20];
int age;
};
int main()
{
student class3[31];
FILE *fp=fopen("d:\\input.txt","r");
fscanf(fp,"%s%s%d",class3[0].sno,class3[0].sname,&class3[0].age);
fclose(fp);
fp=fopen("d:\\output.txt","w");
printf("%s %s %d",class3[0].sno,class3[0].sname,class3[0].age);
fclose(fp);
return 0;
}

#include<stdio.h>
struct student{
char sno[10];
char sname[20];
int age;
};
student s1;
void addStudent()
{
FILE *fp=fopen("d:\\student.txt","a+");
printf(学号:");
scanf("%s",s1.sno);
printf("姓名:");
scanf("%s",s1.sname);
printf("年龄:");
scanf("%s",&s1.age);
fprintf(fp,"\n%s %s %d",s1.sno,s1.sname,s1.age);
printf("信息添加成功。\n");
}
void queryStudent()
{
printf("query");
}
void updateStudent()
{
printf("update");
}
void deleteStudent()
{
printf("delete");
}
void mainmenu()
{
int choice;
printf("学生管理系统\n");
printf("1.添加学生信息\n");
printf("2.查询学生信息\n");
printf("3.修改学生信息\n");
printf("4.删除学生信息\n");
printf("请选择:");
scanf("%d",&choice);
switch(choice)
{
case 1:
addStudent();
break;
case 2:
queryStudent();
break;
case 3:
updateStudent();
break;
case 4:
deleteStudent();
break;
default:
printf("输入有误,程序退出!");
}
}
int main()
{
mainmenu();
}

c语言第12次作业