C高级最后一天

函数部分:

#include  
     2	#include "03_head.h"
     3	void enter_Stu(Stu *p,int k)//录入学生
     4	{
     5		printf("请输入姓名");
     6		char name[20];
     7		scanf("%s",name);
     8		printf("请输入年龄");
     9		int age;
    10		scanf("%d",&age);
    11		printf("请输入成绩");
    12		int score;
    13		scanf("%d",&score);
    14		printf("请输入学号");
    15		int sid;
    16		scanf("%d",&sid);
    17		strcpy((p+k)->name,name);
    18		(p+k)->age = age;
    19		(p+k)->t.score = score;
    20		(p+k)->flag = 's';
    21		(p+k)->f.sid = sid;
    22		return;
    23	
    24	}
    25	void enter_Ter(Ter *p,int k)//录入老师
    26	{
    27		printf("请输入姓名");
    28		char name[20];
    29		scanf("%s",name);
    30		printf("请输入年龄");
    31		int age;
    32		scanf("%d",&age);
    33		printf("请输入绩效");
    34		int pofomance;
    35		scanf("%d",&pofomance);
    36		printf("请输入工号");
    37		int tid;
    38		scanf("%d",&tid);
    39		strcpy((p+k)->name,name);
    40		(p+k)->age = age;
    41		(p+k)->t.pofomance = pofomance;
    42		(p+k)->flag = 't';
    43		(p+k)->f.tid=tid;
    44		return;
    45	}
    46	void seek(Stu *p,int k)//查找
    47	{
    48		int id;
    49		printf("请输入号码>>>>>");
    50		scanf("%d",&id);
    51		int i = 0;
    52		for(i=0;if.sid || id == (p+i)->f.tid)
    55			{
    56	
    57				printf("%s\t%d\t",(p+i)->name,(p+i)->age);
    58				if('s' == (p+i)->flag)
    59				{
    60					printf("%d\t%d\t学生\n",(p+i)->t.score,(p+i)->f.sid);
    61				}
    62				else
    63				{
    64					printf("%d\t%d\t老师\n",(p+i)->t.pofomance,(p+i)->f.tid);
    65				}
    66			}
    67		}
    68	}
    69	void delect()//删除
    70	{
    71		
    72	
    73	}
    74	void show_msg(Stu* p,int k)//遍历
    75	{
    76		for(int i=0;iname,(p+i)->age);
    79			if('s' == (p+i)->flag)
    80			{
    81				printf("%d\t%d学生\n",(p+i)->t.score,(p+i)->f.sid);
    82			}
    83			else
    84			{
    85				printf("%d\t%d老师\n",(p+i)->t.pofomance,(p+i)->f.tid);
    86			}
    87		}
    88		return;
    89	}
头文件部分::
	#ifndef _HEAD_H_
     2	#define _HEAD_H_
     3	#include 
     4	union msg
     5	{
     6		int score;
     7		short pofomance;
     8	};
     9	union nid
    10	{
    11		int tid;
    12		int sid;
    13	};
    14	typedef struct
    15	{
    16		char name[20];
    17		int age;
    18		union msg t;
    19		union nid f;
    20		char flag;
    21	}Stu,Ter;
    22	void enter_Ter(Ter *p,int k);
    23	void enter_Stu(Stu *p,int k);
    24	void show_msg(Stu* p,int k);
    25	void seek(Stu *p,int k);
    26	#endif
代码部分:::
    1	#include 
     2	#include "03_head.h"
     3	int main(int argc, const char *argv[])
     4	{
     5		int select = 0;
     6		int index = 0;
     7		Stu info[10];
     8	
     9		while(1)
    10		{
    11			printf("'1' 录入学生\n");
    12			printf("'2' 录入老师\n");
    13			printf("'3' 遍历\n");
    14			printf("'4' 查询\n");
    15			printf("'5' 删除\n");
    16			printf("'6' 修改\n");
    17			printf("'7' 退出\n");
    18	
    19			printf("请输入>>>>>>>");
    20			scanf("%d",&select);
    21			switch(select)
    22			{
    23			case 1:
    24				//录入学生
    25				enter_Stu(info,index);
    26				index++;
    27				break;
    28			case 2:
    29				enter_Ter(info,index);
    30				index++;
    31				break;
    32			case 3:
    33				show_msg(info,index);
    34				break;
    35			case 4:
    36				seek(info,index);
    37				break;
    38			case 5:
    39				break;
    40			case 6:
    41				break;
    42			case 7:
    43				goto Founce;
    44			default:
    45				printf("输入错误");
    46			}
    47		}
    48	Founce:
    49		return 0;
    50	}

makefile代码

头文件部分
 Obj:=01_zhu.o 02_func.o     
 Target:=a.out               
                             
 CC:=gcc                     
 CAN:=-c -o
-include ./makefile.cfg        

                               
$(Target):$(Obj)               
    $(CC) $^ -o $@

%.o:%.c
    $(CC) $< $(CAN) $@


clear:
    rm $(Obj) $(Target)

你可能感兴趣的:(c语言,算法,开发语言)