学生成绩管理系统实习

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#define LEN sizeof(strUCt scorenode)
#define DEBUG
#include <string.h>
struct scorenode
{int number;/*学号*/
char name[10];/*姓名*/
float yuwen;/*语文成绩*/
float yingyu;/*英语成绩*/
float shuxue;/*数学成绩 */
struct scorenode *next;
};
typedef struct scorenode score;
int n,k;/*n,k为全局变量,本程序中的函数均可以使用它*/
/*==================================================================================*/
score *creat2311(void)
/*函数creat2311,功能:创建链表,此函数带回一个指向链表头的指针*/
{
 score*head;
 score *p1,*p2,*p3,*max;
 int i,j;
 float fen;
    char t[10];
  n=0;
     p1=p2=p3=(score *)malloc(LEN);head=p3; /*开辟一个新单元*/
       printf("请输入学生资料,输0退出! ");
repeat1: printf("请输入学生学号(学号应大于0):");/*输入学号,学号应大于0*/
       scanf("%d",&p1->number);
     while(p1->number<0)
   {getchar();
    printf("输入错误,请重新输入学生学号:");
       scanf("%d",&p1->number);}      
  /*输入学号为字符或小于0时,程序报错,提示重新输入学号*/
  if(p1->number==0)
   goto end;/*当输入的学号为0时,转到末尾,结束创建链表*/
  else
  {
  p3=head;
  if(n>0)
   {for(i=0;i<n;i++)
           {if(p1->number!=p3->number)
     p3=p3->next;
     else
     {printf("学号重复,请重输! ");
     goto repeat1;
     /*当输入的学号已经存在,程序报错,返回前面重新输入*/
        }
    }    
   }         
  }
       printf("请输入学生姓名:");
       scanf("%s",&p1->name);/*输入学生姓名*/
       printf("请输入语文成绩(0~100):");/*输入语文成绩,成绩应在0-100*/
       scanf("%f",&p1->yuwen);
    while(p1->yuwen<0p1->yuwen>100)
 {getchar();
  printf("输入错误,请重新输入语文成绩");/*输入错误,重新输入语文成绩直到正确为止*/
            scanf("%f",&p1->yuwen);}
       printf("请输入英语成绩(0~100):");/*输入英语成绩,成绩应在0-100*/
       scanf("%f",&p1->yingyu);
    while(p1->yingyu<0p1->yingyu>100)

共15 页 首页 上一页 [1] [2] [3] [4] [5下一页 尾页>
上一篇: socket编程原理
下一篇:
赞助商广告