线性表——链式 学生系统不完全版 c语言版

数据结构课学到东西   在上机课只实现一小部分,因为没带电脑其余部分以后用c++全部写出来再发一次

头文件部分  head.h

#include<stdio.h>  
#include<ctype.h>  
#include<stdlib.h>  
#include<string.h>  
    struct zhifu  
    {  
        int no;  
        char name[20];  
        char sex[5];  
        int english;
		int math;
		int total;
		float average;
        struct zhifu *next;  
    }; 
char test='\0'; 
struct zhifu *first = NULL;  
struct zhifu *ing = NULL;  
struct zhifu *previous = NULL;
void bulid()
{
	for(;;)  
 {  
    printf("\n你想继续输入学生数据吗(Y or N)?\n");
    scanf("%c",&test);  
	getchar();
    if(tolower(test)=='n')  
        break;  
   
    ing=(struct zhifu*)malloc(sizeof(struct zhifu));  
   
    if(first==NULL)  
        first =ing;  
   
    if(previous!=NULL)  
        previous->next=ing;  
    printf("\n这是第几学号学生的数据:");  
    scanf("%d",&ing->no);  
    printf("\n请定义学号为%d的学生姓名:",ing->no);  
    scanf("%s",ing->name);
	printf("\n请定义学号为%d次学生性别:",ing->no);
	scanf("%s",ing->sex);
    getchar();     
    ing->next=NULL;  
    previous=ing;  
  }  
}
void show()
{if(ing!=NULL)
  {
	  for (ing = first; ing != NULL; ing = ing->next) 
	  {  
        printf("%d   %s   ", ing->no, ing->name);
		printf("%s   %d   %d   ",ing->sex,ing->english,ing->math);
		printf("%d   %f\n",ing->total,ing->average);
      }  
	
  }
else
 printf("\n没有内容,有待添加\n");
}


main部分

 

#include"head.h"
int main()
{
	int www;
	while(1)
	{

		printf("\n\tstudent's master\n");
	    printf("\t1.show_student\n");
	    printf("\t2.find_student\n");
	    printf("\t3.change_student\n");
	    printf("\t4.add_student\n");
		printf("\t5.bulid_student\n");
	    printf("\t6.exit\n");
		printf("\t\tplease input(1~6): ");
	    scanf("%d",&www);
		switch(www){
		case 1: show();break;
		//case 2: find();
		//case 3: change();
		//case 4: add();
		case 5: bulid();break;
		case 6: return 0;break;
		default: printf("\ninput erro,please input again\n");
		
		}  
	}




}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值