当前位置:首页 > 问答大全 > 学生成绩管理系统 c语言

学生成绩管理系统 c语言

被浏览: 0次 2023年08月12日 21:56
热门回答(4个)
游客1

经达Turbo C++测试仿桥的:
#include
#define STUDEN_TOTAL 3
void CopyString(char *dst,char *src,int length)
{
int i;
for(i=0; i {
dst[i] = src[i];
}
}
void main()
{
struct studen_S
{
int no;
char name[20];
int record_fox;
int record_c;
int record_en;
int record_total;
}studen[STUDEN_TOTAL],stu_temp;
int item;
int i,j;
int studen_count=0;

while(1)
{
printf("\n");
printf("1: Input the records of studen\n");
printf("2: Count the records of studen\n");
printf("3: Sort the records of studen\n");
printf("4: Query the information of studens\n");
printf("0: exit\n");
printf("Please input a nunber select the itme:");
scanf("%d",&item);
if(item == 0)
break;
printf("\n"嫌衫);

switch(item)
{
case 1:
if(studen_count >= STUDEN_TOTAL)
printf("The count of studens is full!\n");
else
{
printf("Plese input the information of studen:[no] [name] [fox] [c] [en]\n");
for(i=studen_count; i {
scanf("%d %s %d %d %d",&studen[i].no,&studen[i].name,&studen[i].record_fox,&studen[i].record_c,&studen[i].record_en);
studen_count ++;
}
}
break;
case 2:
if(studen_count == 0)
printf("The information of studens is empty!\n");
else
{
printf("Count the total record of studens...\n");
for(i=0; i {
studen[i].record_total = studen[i].record_fox + studen[i].record_c + studen[i].record_en;
printf("%-19s's total record is: %d\n"芹大腔,studen[i].name,studen[i].record_total);
}
}
break;
case 3:
printf("Sort the total record of studens...\n");
for(i=0; i {
for(j=i; j {
if(studen[i].record_total < studen[j].record_total)
{
stu_temp.no = studen[i].no;
//stu_temp.name[0] = studen[i].name[0];
CopyString(stu_temp.name,studen[i].name,20);
stu_temp.record_fox = studen[i].record_fox;
stu_temp.record_c = studen[i].record_c;
stu_temp.record_en = studen[i].record_en;
stu_temp.record_total = studen[i].record_total;
studen[i].no = studen[j].no;
CopyString(studen[i].name,studen[j].name,20);
studen[i].record_fox = studen[j].record_fox;
studen[i].record_c = studen[j].record_c;
studen[i].record_en = studen[j].record_en;
studen[i].record_total = studen[j].record_total;
studen[j].no = stu_temp.no;
CopyString(studen[j].name,stu_temp.name,20);
studen[j].record_fox = stu_temp.record_fox;
studen[j].record_c = stu_temp.record_c;
studen[j].record_en = stu_temp.record_en;
studen[j].record_total = stu_temp.record_total;
}
}
}
printf("Number Name Fox C Englis Total\n");
for(i=0; i {

printf("%-7d%-10s%-6d%-6d%-6d%-6d\n",studen[i].no,studen[i].name,studen[i].record_fox,studen[i].record_c,studen[i].record_en,studen[i].record_total);
}
break;
case 4:
printf("Please input the number of studen: ");
scanf("%d",&j);
for(i=0; i {
if(studen[i].no == j)
break;
}
printf("Number: %d\n",studen[i].no);
printf("Name : %s\n",studen[i].name);
printf("Fox : %d\n",studen[i].record_fox);
printf("C : %d\n",studen[i].record_c);
printf("Englis: %d\n",studen[i].record_en);
printf("Total : %d\n",studen[i].record_total);
break;
default:
break;
}
}
}

游客2

这个问题 只能用链表或者文件来实现

#include
#include
#include
using namespace std;

struct lx
{
long num;
char name[20];
struct lx *link;
};

struct lx *addlist(struct lx *head,long x);//添加节点;
void listclear(struct lx *head);
struct lx *createlist(void );
void listprintf(struct lx *p);

int main(int argc,char **argv)
{
long x;
struct lx *p = createlist();
listprintf(p);
cout<<"输入学手告橡号"< cin>> x;
struct lx *head = addlist(p,x);
listprintf(head);
listclear(head);
//listprintf(temp);
return 0;
}
struct lx *createlist(void )
{
struct lx *head ;
struct lx *tail ;
struct lx *p;
char buf[20];
head = NULL;

p = (struct lx *)malloc(sizeof (struct lx));

// cout<< "内存分配失败!!!!"<< endl;

cout<< "请输入学号:";
cin>> p->num;

cout<毕旁< "请输入姓名:";
cin>> p->name;
//cout< //strcpy(p->name, buf);
while(1)
{

if(head == NULL)
{
head = p;
tail = p;
}

else
{
tail->link = p;
tail = p;
}

p = (struct lx*)malloc(sizeof(struct lx));

// cout<<"内存分配友谨失败!!!!!"<< endl;

cout<< "请输入学号:";
cin>> p->num;
if(p->num == 0)
break;
cout<< "请输入姓名:";
cin>> p->name;
//strcpy(p->name,buf);
}
tail->link = NULL;

return head;
}

void listprintf(struct lx *p)
{
struct lx* q = p;
while(q!= NULL)
{

cout<< q->num< cout<< q->name< q = q->link;
}

}
struct lx *addlist(struct lx *head,long x)//添加节点
{
struct lx *p = head;
struct lx *q,*temp,*temp1;
q = NULL;

if(p->link == NULL )
{
if((p->num ) > x )
{
q=(struct lx *)malloc(sizeof(struct lx));
cout<<"输入姓名:"< cin>>q->name;
q->num = x;
q->link = p;
p = q;
}

else
{
q=(struct lx *)malloc(sizeof(struct lx));
cout<<"输入姓名:"< cin>>q->name;
q->num = x;
temp1 = p->link;
p->link = q;
q->link = temp1;
temp1->link = NULL;
}

}
else if(((p->num) > x)&&((p->link)->link == NULL))
{
q=(struct lx *)malloc(sizeof(struct lx));
cout<<"输入姓名:"< cin>>q->name;
q->num = x;
p->link = q;
q->link = p;
q->link = NULL;
}
else
{
while(1)
{
if((p->num < x)&&((p->link)->num > x))
break;
p = p->link;
}

q=(struct lx *)malloc(sizeof(struct lx));
cout<<"输入姓名:"< cin>>q->name;
q->num = x;
temp = p->link;
p->link = q;

q->link = temp;
}
return p;
}

void listclear(str

游客3

这是当初我做的那个,用链表做的,各项都能实现好好熟悉一下,希望对你有帮助

#include
#include
#include
struct stud_node{
int num;
char name[20];
int score;
struct stud_node *next;
};
struct stud_node * Create_Stu_Doc(); //新建链表
struct stud_node * InsertDoc(struct stud_node * head,struct stud_node * stud); //慎塌液插入
struct stud_node * DeleteDoc(struct stud_node * head,int num); //删除
void Print_Stu_Doc(struct stud_node * head); //遍历
int main(void)
{
struct stud_node * head,*p;
int choice,num,score;
char name[20];
int size=sizeof(struct stud_node);

do{
printf("1:Create 2:Insert 3:Delete 4:Print 0:Exit\n");
scanf("%d",&choice);
switch(choice){
case 1:
head=Create_Stu_Doc();
break;
case 2:
printf("Input nun,nameand score:\n");
scanf("%d%s%d",&num,name,&score);
p=(struct stud_node * )malloc(size);
p->num=num;
strcpy(p->name,name);
p->score=score;
head=InsertDoc(head,p);
break;
case 3:
printf("Input num:\n");
scanf("%d",&num);
head=DeleteDoc(head,num);
break;
case 4:
Print_Stu_Doc(head);
break;
case 0:
break;
}
}while(choice!=0);
return 0;
}
//新建链表
struct stud_node * Create_Stu_Doc()
{
struct stud_node * head,*p;
int num,score;
char name[20];
int size=sizeof(struct stud_node);

head=NULL;
printf("Input num,name,score:\n");
scanf("%d%s%d",&num,name,&score);
while(num!=0){
p=(struct stud_node * )malloc(size);
p->num=num;
strcpy(p->name,name);
p->score=score;
head=InsertDoc(head,p);
scanf("%d%s%d"衫拿,&num,name,&score);
}
return head;
}
//插入操作
struct stud_node * InsertDoc(struct stud_node * head,struct stud_node * stud)
{
struct stud_node *ptr,*ptr1, *ptr2;

ptr2=head;
ptr=stud; //ptr指向待插入的新的学生记录结点
//原链表为空时的插入
if(head==NULL){
head=ptr; //新插入结点成为头结点宽物
head->next=NULL;
}
else{ //原链表不为空时的插入
while((ptr->num>ptr2->num)&&(ptr2->next!=NULL)){
ptr1=ptr2;
ptr2=ptr2->next;
}
if(ptr->num<=ptr2->num){
if(head==ptr2) head=ptr;
else ptr1->next=ptr;
ptr->next=ptr2;
}
else{ //新插入结点成为尾结点//

ptr2->next=ptr;
ptr->next=NULL;
}
}
return head;
}
//删除操作//
struct stud_node * DeleteDoc(struct stud_node * head,int num)
{
struct stud_node * ptr1,*ptr2;
//要被删除的结点为表头结点
while(head!=NULL && head->num==num){
ptr2=head;
head=head->next;
free(ptr2);
}
if(head==NULL) //链表空
return NULL;
//要被删除的结点为非表头结点
ptr1=head;
ptr2=head->next; //从表头的下一个结点搜索所有符合删除要求的结点

while(ptr2!=NULL){
if(ptr2->num==num){
ptr1->next=ptr2->next;
free(ptr2);
}
else
ptr1=ptr2;
ptr2=ptr1->next;
}
return head;
}

//遍历操作
void Print_Stu_Doc(struct stud_node * head)
{
struct stud_node * ptr;
if(head==NULL){
printf("\nNo Record\n");
return;
}
printf("\nThe Student Records Are: \n");
printf(" Num name score\n");
for(ptr=head;ptr;ptr=ptr->next)
printf("%8d %20s %6d\n",ptr->num,ptr->name,ptr->score);
}

游客4

两年前做的,现贺帆在都不会C语言了。
下面的代码应该是对的。没有注释,但应该能看的懂,起名字也很不规范。只有信息输入、和查询,还有平均成绩。不求得分,只是拿出来共享一下,提供个参考。

#include
#include
#define pl 64
void fine(int size[][6],char xh[][5],char name[][9])
{
int i,a,b;
char d[5];
for(;;)
{
printf("请输入要查拍拍祥找的袭搏学号或姓名:");
scanf("%s",d);
for(i=0;i if(strcmp(d,xh[i])==0||strcmp(d,name[i])==0)
{
printf("学号:%s\t",xh[i]);
printf("姓名:%s\n",name[i]);
printf("成绩:");
for(a=0;a<5;a++)
{
printf("%d ",size[i][a]);
}

printf("\n平均成绩:%d\n\n",size[i][5]);
}
}

}
void main()
{
int size[pl][6],a,i;
char b, name[pl][9], xh[pl][5];
for(i=0;i {
printf("学号:");
scanf("%s",xh[i]);
printf("姓名:");
scanf("%s",name[i]);
printf("成绩:");
size[i][5]=0;
for(a=0;a<5;a++)
{
scanf("%d",&size[i][a]);
size[i][5]+=size[i][a];
}
size[i][5]/=5;
}

for(i=0;i {
printf("学号:%s\t",xh[i]);
printf("姓名:%s\n",name[i]);
printf("成绩:");
for(a=0;a<5;a++)
{
printf("%d ",size[i][a]);
}

printf("\n平均成绩:%d\n",size[i][5]);
}
fflush(stdin);
printf("是否要查找:y or n:\n");
scanf("%c",&b);
if(b=='y'||b=='Y')
fine(size,xh,name);
}