#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define maxsize 20
typedef int intype;
typedef char chtype;
typedef float gratype;
typedef struct DATA1
{
chtype name[6];
intype age;
intype id;
chtype sex[2];
intype classes;
gratype English;
gratype Maths;
gratype Chinese;
}primary;
typedef struct LNode
{
primary adata;
struct LNode *anext;
}point,*link;
link acreate()
{
point *q,*ahead,*L;
intype i,n,k,j;
L=ahead=(point*)malloc(sizeof(point));
ahead->anext=NULL;
printf("請輸入小學生的個數:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
L->anext=(point*)malloc(sizeof(point));
printf("\n請按指示輸入第%d個小學生的資訊:\n",i+1);
printf("姓名:");
scanf("%s",&L->adata.name);
printf("學號:");
scanf("%d",&L->adata.id);
for(k=0;k<i;k++)
{
q=ahead->anext;
if(q->adata.id==q->anext->adata.id)
{
printf("資料重復,添加失敗!\n");
q->anext=NULL;
q=q->anext;
j=1;
continue;
}
q=q->anext;
}
if(j==1) continue;
printf("年齡:");
scanf("%d",&L->adata.age);
printf("性別:");
scanf("%s",&L->adata.sex);
printf("班級:");
scanf("%d",&L->adata.classes);
printf("英語分數:");
scanf("%f",&L->adata.English);
printf("數學分數:");
scanf("%f",&L->adata.Maths);
printf("語文分數:");
scanf("%f",&L->adata.Chinese);
L=L->anext;
L->anext=NULL;
}
return ahead;
}
void main()
{
point *L;
L=acreate();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/84958.html
標籤:疑難問題
下一篇:mysql全文索引無效問題
