120.c

来自「C语言算法举例.rar」· C语言 代码 · 共 34 行

C
34
字号
#define   NULL  0

#define   LEN     sizeof(struct grade)
struct  grade
   { char  no[7];				
      int  score;				
      struct  grade  *next;			
    };
struct grade *create( void )
    { struct grade *head=NULL, *new, *tail;
        int count=0;             		
        for(  ;   ;  )              		
     	  { new=(struct grade *)malloc(LEN);	

printf("Input the number of student No.%d(6 bytes): ", count+1);
scanf("%6s", new->no);
if(strcmp(new->no,"000000")==0)    
      { free(new);              	      	
         break;                    	      	       }
printf("Input the score of the student No.%d: ", count+1);
scanf("%d", &new->score);
count++;                     		
new->next=NULL;

if(count==1)  head=new;  
      else  tail->next=new;       
       tail=new;                         
     }
   return(head);
}						



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?