示例#1
0
文件: LinkList2.c 项目: wugsh/wgs
int main()
{
    int i, di;
    ELemType e, de;

    linklist *L = (linklist *)malloc(sizeof(linklist));
    if (!L)
        return ERROR;
    printf("creat a linklist\n");
    CreatList(L);
    printf("L = %d \n", L->next->data);
    display(L);
    //linklist *m;
   // m = L;
    //display(L);
    reverse(L);
    display(L);
    printf("please input the insert lo & elem:\n");
    scanf("%d %d", &i, &e);
    listinsert(L, i, e);
    printf("please input the del number:\n");
    scanf("%d", &di);
    listdel(L, di, &de);
    display(L);
    free(L);
    return 0;

}
示例#2
0
int main()
{
	char ch[10],num[5];
	LinkList head;
	head=CreatList();
	printlist(head);
	printf(" Delete node (y/n):");
	scanf("%s",num);
	if(strcmp(num,"y")==0||strcmp(num,"Y")==0) 
	{
		printf("Please input Delete_data:");
		scanf("%s",ch);
		DeleteList(head,ch);
		printlist(head);
	}
	printf("Add node ? (y/n): ");
	scanf("%s",ch);
	if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
	{
		head=AddNode(head);
	}
	printlist(head);
	system("pause");
	DeleteAll(head);
}
示例#3
0
int main(void)
{
	pNode pHead = (pNode)malloc(sizeof(Node));
	pHead = CreatList();
	printf("%d", FindKthToTail(pHead,3));
	/*TraverseList(pHead);*/
	return 0;
}
示例#4
0
文件: list.cpp 项目: keitee/kb
TEST(ListTest, checkEmpty) {
  List list;
  CreatList(&list);

  EXPECT_EQ( 1, ListEmpty(&list) );

  // to make fail
  // EXPECT_EQ( 0, ListEmpty(&list) );     // note: line #112 
}
示例#5
0
int main(void)
{
    int n =41,m=3;
    LHead *list_head;
    list_head = (LHead*)malloc(sizeof(LHead));
    CreatList(&list_head,n);
    Print(&list_head);

    printf("\n约瑟夫问题(人数 %d 人,序号为 %d 的倍数的人自杀)的解为:\n",n,m);
    Josephus(&list_head,n,m);
}
示例#6
0
文件: main.cpp 项目: nilzyj/test
int main(void)
{
    Node *head;
    head=CreatList();
    printf("链表逆置前的数据:\n");
    PrintList(head);
    head=ReverseList(head);
    printf("链表逆置后的数据:\n");
    PrintList(head);
    return 0;
}
示例#7
0
文件: 90.c 项目: noparkinghere/C_test
int main(void)
{
	pstruNode head;
	int num;
	printf("input the numbers:");
	scanf("%d", &num);

	head = CreatList(num);
	OutList(head, num);
	RevList(head, num);
	OutList(head, num);
}
示例#8
0
int main(int argc, char *argv[])
{
    int n = 0;
    int m = 0;
    NodeType *pHead = NULL;
    do {
        scanf("%d",&n);
    } while(n > MAX);
    scanf("%d",&m);
    CreatList(&pHead, n);           //创建单向循环链表
    JosephusOperate(&pHead, m);     //运行约瑟夫环问题

    return 1;
}
int main(void)
{
	int n=0;
	int m=0;
	NodeType *phead=NULL;
	do
	{
		if(n > Max)
		{
			printf("人数太多,请重新输入!\n");
		}
		printf("请输入人数:\n");
		scanf("%d",&n);
	}while(n > Max);
	printf("请输入初始密码:\n");
	scanf("%d",&m);
	CreatList(&phead, n);
	printf("-------------打印循环链表-------------\n");
	PrntList(phead);
	printf("-------------打印出队情况-------------\n");
	JosephusOperate(&phead, m);
	return 1;
}