示例#1
0
void n_p(struct list * a)//往链表尾添加一个新成员
{
	struct peo_info * p;
	p=a->h;
	while(p->next!=NULL)
		p=p->next;
	p->next=(struct peo_info *)malloc(sizeof(struct peo_info));
	input_p(p->next);
	p->next->next=NULL;
	a->l++;
}
示例#2
0
int main()
{
	struct student s;
	struct student s1[10];
	int n,d,ch2,ch1;
	printf("enter the number of records  to be entered");
	scanf("%d",&n);
	printf("choose the way to operate:\n 1.with pointer\n 2. without pointer");
	scanf("%d",&ch1);
	switch(ch1)
	{
	case 1:
		{
			input_p(&s,n);

			do
				{
				printf("choose the operation to perform:\n 1.display all\n 2.display particular\n 3.delete\n 4.insert\n 5.bubble sort\n 6.selection sort\n 7.binary seach");
				scanf("%d",&ch2);
				switch(ch2)
				{
					case 1:
						display_all_p(&s,n);
					break;
					case 2:
						printf("enter the record to be displayed");
						scanf("%d",&d);
						display_part_p(&s,d);
					break;
					case 3:
						printf("\n enter the record to be deleted");
						scanf("%d",&d);
						del_p(&s,d,n);
					break;
					case 4:
						printf("\n enter the position at which record is to be inserted");
						scanf("%d",&d);
						ins_p(&s,d,n);
					break;
					case 5:
						printf("you chose to sort the records by their roll no using bubble sort");
						bubblesort(&s,n);

						break;
					case 6:
						printf("you chose to sort the records by their roll no using selection sort");
						selection_sort(&s,n);

						break;
					case 7:
						printf("you chose to search a record using binary search by their roll no");

						bin_search(&s,n);
						break;
					default:
						break;
				}
			}while(ch2!=8);

		}
		break;
	case 2:
		{
			input(s1,n);
			do
			{
				printf("choose the operation to perform:\n 1.display all\n 2.display particular\n 3.delete\n 4.insert\n 5. exit");
				scanf("%d",&ch2);
				switch(ch2)
				{
					case 1:
						display_all(s1,n);
					break;
					case 2:
						printf("enter the record to be displayed");
						scanf("%d",&d);
						display_part(s1,d);

					break;
					case 3:
						printf("\n enter the record to be deleted");
						scanf("%d",&d);
						del(s1,d,n);
					break;
					case 4:
						printf("\n enter the position at which record is to be inserted");
						scanf("%d",&d);
						ins(s1,d,n);
					break;
					default:
						printf("please enter a valid input");
						break;
				}
			}while(ch2!=5);
		}
		break;
	default:
		break;

	}
	getchar();
	return 0;
}