void testcases()
{
    int lv1,lv2=0;
    for(lv1=0; lv1<6; lv1++)
    {
        nodetype *head,*temp;
        head=Create_list(test[lv1].input);
        head=rec_rev(head,head);
        temp=head;
        lv2=0;
        while(temp)
        {
            if(test[lv1].output[lv2++]==temp->data)
            {
                temp=temp->link;
            }
            else
            {
                printf("test%d is failed",lv1+1);
                return ;
            }
        }
        display(head);
    }
    printf("tests are passed");
    return;

}
示例#2
0
int main()
{
	Linked_list *t = new Linked_list;
	Linked_list *w = new Linked_list;
	Create_list(t);
	Create_list(w);

	cout << "Введите текст:" << endl;
	Read(t);
	cout << "Введите фрагмент для поиска:" << endl;
	Read(w);

	if (found(t, w))
		cout << "Заданная последовательность символов является фрагментом текста. " << endl;
	else
		cout << "Заданная последовательность символов не встречается в тексте." << endl;

	return 0;
}
示例#3
0
int main()
{

	Dnode *ptr = Create_list();
	Dnode *rear = ptr->next;
	
	printf("Please input 1 to enqueue or 2 to dequeue or 0 to end program : ");

	int in;
	while(scanf("%d",&in)!=EOF)
	{
		int input;
			if(in==1)
			{

				printf("Please input a number to enqueue : ");
				scanf("%d",&input);

				enqueue(ptr,input);
				
			}
			else if(in==2)
			{
				dequeue(rear);
			}
			else if(in==0)
				break;
			Dnode *zz;
			zz = ptr->next;

			int con = 0;

			while(zz!=rear)
			{
				con = 1;
				printf("%d ",zz->number);
				zz = zz->next;
			}
			if(con==0)
				printf("NULL");

		printf("\nPlease input 1 to enqueue or 2 to dequeue or 0 to end program : ");
	}

	delete_queue(ptr);							//Delete queue before the end of program.
	int det = determine_free();
	if(det)
		printf("All the memory are under control and eventually free back to the system\n");
	else
		printf("The memory leak has happened!\n");



	return 0;
}
示例#4
0
int main(int argc, char* argv[])
{
	//struct Player *player = Create_player("Hessu Hopo", 609);
	//Print_player(player);
	//free(player);
	struct Player_list *list = Create_list();
	Add_player("Hessu Hopo", 609, list);
	Add_player("Hessu 23", 333, list);
	Print_list(list);
	free(list);
	return 0;	
}
int main()
{
		
	Dnode *ptr = Create_list();
	
	printf("Please input 1 to push or 2 to pop or 0 to end program : ");

	int in;
	while(scanf("%d",&in)!=EOF)
	{
		long input;
			if(in==1)
			{

				printf("Please input a number to push in : ");
				scanf("%ld",&input);

				Stack_push(ptr,input);
			}
			else if(in==2)
				Stack_pop(ptr);
			else if(in==0)
				break;
			Dnode *zz;
			zz = ptr->next;

			int con = 0;

			while(zz->next!=NULL)
			{
				con = 1;
				printf("%ld\n",zz->data);
				zz = zz->next;
			}
			if(con==0)
				printf("NULL\n");

		printf("Please input 1 to push or 2 to pop or 0 to end program : ");
	}


	return 0;
}