c语言程序设计实习报告程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
printf("请输入英语成绩:");scanf("%f",&students[num].Mark2);getchar();
printf("请输入数学成绩:");scanf("%f",&students[num].Mark3);getchar();
students[num].Average=Avg(students[num]);
scanf("%s",&students[index].Name);
getchar();
printf("请输入成绩:");
scanf("%f",&students[index].Mark1);
getchar();
printf("请输入成绩:");
scanf("%f",&students[index].Mark2);
void Student_DisplaySingle(int index)
{printf("%10s%10s%8s%8s%8s%8s%10s\n","学号","姓名","计算机","英语","数学","总分","平均成绩");
printf("-------------------------------------------------------------\n");
}void Student_DisplaySingle1(int index)
{printf("-------------------------------------------------------------\n");
printf("%10s%10s%8.0f%8.0f%8.0f%8.0f%10.2f\n",students[index].ID,students[index].Name,
{
return i;
}}
return -1;
}
/*通过姓名返回数组下标*/
int Student_SearchByName(char name[]){
int i;
for (i=0;i<num;i++)
{if (strcmp(students[i].Name,name)==0)
{return i;}}
{printf("请输入学号:");scanf("%s",&students[num].ID);getchar();
printf("请输入姓名:");scanf("%s",&students[num].Name);getchar();
printf("请输入计算机成绩:");scanf("%f",&students[num].Mark1);getchar();
{return (stu.Mark1+stu.Mark2+stu.Mark3)/3;}
/*通过学号返回数组下标*/
int Student_SearchByIndex(char id[])
{ int i;
for (i=0;i<num;i++)
{
if (strcmp(students[i].ID,id)==0)
while(1)
{
char id[20];
int index;
printf("请输入要修改的学生的学号:");
scanf("%s",&id);
getchar();
index=Student_SearchByIndex(id);
if (index==-1)
{
printf("学生不存在!\n");
}
else
/*声明学生数组及学生数量*/
struct Student students[2000];
int num=0;
/*求总分*/
float Zong(struct Student stu)
{
return(stu.Mark1+stu.Mark2+stu.Mark3);
}
/*求平均值*/
float Avg(struct Student stu)
printf("%10s%10s%8.0f%8.0f%8.0f%8.0f%10.2f\n",students[index].ID,students[index].Name,
students[index].Mark1,students[index].Mark2,students[index].Mark3,students[index].Zongfen,students[index].Average);
students[num]Fra Baidu bibliotekZongfen=Zong(students[num]);
num++;
printf("是否继续?(y/n)");
if (getchar()=='n'){break;}
}}
void exit() ;
/*修改学生信息*/
void Student_Modify()
{
float mark1,mark2,mark3;
{
printf("你要修改的学生信息为:\n");
Student_DisplaySingle(index);
printf("--请输入新值--\n");
printf("请输入学号:");
scanf("%s",&students[index].ID);
getchar();
printf("请输入姓名:");
students[index].Mark1,students[index].Mark2,students[index].Mark3,students[index].Zongfen,students[index].Average);
}
/*插入学生信息*/
void Student_Insert()
{while(1)
return -1;}
/*通过学号返回数组下标*/
int Student_SearchID(char id[]){
int i;
for (i=0;i<num;i++)
{if (strcmp(students[i].ID,id)==0)
{return i;}}
return -1;}
/*显示单条学生记录*/
#include "stdio.h"
/*定义学生结构体*/
struct Student
{
char ID[20];
char Name[20];
float Mark1; /*计算机*/
float Mark2; /*英语*/
float Mark3; /*数学*/
float Zongfen; /*总分*/
float Average;}; /*平均分*/
相关文档
最新文档