当前位置: 首页>>代码示例>>C++>>正文


C++ CreateList函数代码示例

本文整理汇总了C++中CreateList函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateList函数的具体用法?C++ CreateList怎么用?C++ CreateList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateList函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char const *argv[])
{
	List L1, L2, L3;
	Position P;

  L1 = CreateList(3);
  PrintList(L1);

  L2 = CreateList(5);
  PrintList(L2);
  
  L3 = CreateList(2);
  PrintList(L3);

	for (P = L1; P -> next != NULL; P = P -> next);
	P -> next = L3;

  PrintList(L1);

 	for (P = L2; P -> next != NULL; P = P -> next);
	P -> next = L3; 

  PrintList(L2);
	
	printf("%d\n", getIntersectionNode(L1, L2) -> val);
	return 0;
}
开发者ID:yangmiemie,项目名称:leetcode,代码行数:27,代码来源:intersection_of_two_linked_lists.c

示例2: main

int main(void)
{
    Sqlist lc,ld,lb,la;
    int e,locale,pos,elem;
    init_list(&lc);
    CreateList(&lc);
    print(lc);
    printf("Please enter the elem your want to find:\n");
    scanf("%d",&e);
    locale = location(&lc, e);
    printf("the location of elem is %d\n",locale);
    printf("Please enter the insert position and the elem:\n");
    scanf("%d%d",&pos,&elem);
    List_Insert(&lc,pos,elem);
    printf("after insert elem ,the Sqlist is:\n");
    print(lc);


    printf("Please enter the insert position and the elem:\n");
    scanf("%d%d",&pos,&elem);
    List_Del(&lc,pos,elem);
    printf("after delete elem ,the Sqlist is:\n");
    print(lc);

    init_list(&ld);
    init_list(&la);
    CreateList(&la);
    init_list(&lb);
    CreateList(&lb);
    Combine(la,lb,&ld);
    print(ld);

    return 0;
}
开发者ID:fairytalefu,项目名称:Datastruct,代码行数:34,代码来源:Sqlist.c

示例3: CreateList

List *Ast::CreateList(const location& loc, ExprContext ctx, AstNode *seq, AstNode *item)
{
	List *tuple = NULL;
	if (seq)
	{
		tuple = dynamic_cast<List*>(seq);

        if(!tuple)
        {
            tuple = CreateList(loc, ctx);
            tuple->items.push_back(seq);
        }
	}
	else
	{
		tuple = CreateList(loc, ctx);
	}

    if(item)
    {
        tuple->items.push_back(item);
    }

    return tuple;
}
开发者ID:AndySomogyi,项目名称:cayman,代码行数:25,代码来源:Ast.cpp

示例4: main

int main()
{
	ListNode* l1 = NULL;
	CreateList(l1,3); // 输入数据,长度为3
	ListNode* l2 = NULL;
	CreateList(l2,3);
	Solution sln;
	ListNode* results = NULL;
	results = sln.addTwoNumbers(l1,l2);
	print(results);
    while(1);
	
	return true;
}
开发者ID:guker,项目名称:MyLeetcode,代码行数:14,代码来源:Add_Two_Numbers.cpp

示例5: main

int main()
{
   List L1, L2;
   Stack S1, S2;
   Position current1, current2;
   FILE *fpr, *fpi;
   Position current;
   int isPalindrome;

   L1 = CreateEmptyList();
   fpr = fopen("linkedlist1.dat", "r");
   if(fpr == NULL)
   {
      printf("\nFailed to open file!\n");
   }
   CreateList(fpr, L1);

   L2 = CreateEmptyList();
   fpi = fopen("linkedlist2.dat", "r");
   if(fpi == NULL)
   {
      printf("\nFailed to open file!\n");
      exit(0);
   }
   CreateList(fpi, L2);

   PrintList(L1);
   PrintList(L2);

   S1 = CreateEmptyStack();
   S1 = CreateStackFromList(L1, S1);

   S2 = CreateEmptyStack();
   S2 = CreateStackFromList(L2, S2);
   
   PrintStack(S1);
   PrintStack(S2);

   isPalindrome = CheckIsPalindrome(L1, S1);
   if(isPalindrome == 0)
   {
      printf("\nThat list is a Palindrome!\n");
   }
   else
   {
      printf("\nThat list is not a Palindrome!\n");
   }

   isPalindrome = CheckIsPalindrome(L2, S2);
   if(isPalindrome == 0)
   {
      printf("\nThat list is a Palindrome!\n");
   }
   else
   {
      printf("\nThat list is not a Palindrome!\n");
   }

   return 0;
}
开发者ID:cwcarithers,项目名称:m653e292-cs680-sp2014-git-clone,代码行数:60,代码来源:Prog04q2.c

示例6: main

int main(int argc, char const *argv[])
{
  List L1, L2, L3;
  Position P;

  L1 = CreateList(1);
  PrintList(L1);
  printf("%d\n", hasCycle(L1));

  for (P = L1; P -> next != NULL; P = P -> next);
  P -> next = L1;
  printf("%d\n", hasCycle(L1));

  L2 = CreateList(5);
  PrintList(L2);
  printf("%d\n", hasCycle(L2));
  for (P = L2; P -> next != NULL; P = P -> next);
  P -> next = L2;
  printf("%d\n", hasCycle(L2));

  L3 = CreateList(2);
  PrintList(L3);
  printf("%d\n", hasCycle(L3));
  for (P = L3; P -> next != NULL; P = P -> next);
  P -> next = L3;
  printf("%d\n", hasCycle(L3));
  return 0;
}
开发者ID:yangmiemie,项目名称:leetcode,代码行数:28,代码来源:linked_list_cycle.c

示例7: main

//------------------------------------------------------------------------------
int main(){
    auto list = CreateList( std::vector<int>( {1,2,3,4,5} ) );

    std::cout << PrintList( list ) << std::endl;
    std::cout << PrintBackList( list ) << std::endl;

    auto listA = CreateList( std::vector<int>( {1,2,3,} ) );
    auto listB = CreateList( std::vector<int>( {4,5} ) );

    auto ab = Append( listA, listB );

    std::cout << PrintList( ab ) << std::endl;

    auto tree = CreateTree( std::vector<int>( {4,2,1,3,5} ) );

    std::cout << PrintTree( tree ) << std::endl;

    auto treelist = TreeToList( tree );

    std::cout << PrintList( treelist ) << std::endl;

    TestRandomTree();

    return EXIT_SUCCESS;
}
开发者ID:zhensydow,项目名称:ljcsandbox,代码行数:26,代码来源:tree_list_recursion.cpp

示例8: main

int main(int argc, const char *argv[])
{
  Node* head = CreateList();
  int v = 5;
  InsertList(head, v);
  InsertList(head, v);
  InsertList(head, v);
  v = 10;
  int i = InsertList(head, v, 4);
  v = 20;
  i = InsertList(head, v, 4);
  v = 1;
  i = InsertList(head, v);
  printf("i:%d\n", i);
  PList(head);
  printf("\n\n");
  PListRecurse(head->next);

  printf("\nreserve list:\n");
  ReserveList(head);
  PList(head);
  printf("\n---- reserve list\n");

  Node* p = GetNode(head, 1);
  if( NULL != p )
  {
    printf("\n0 node d:%d p:%016lX\n", p->d, reinterpret_cast<uint64_t>(p));
  }

  Node* head2 = CreateList();
  head2->next = p;
  printf("\nlist2\n");
  PList(head2);
  printf("\n");

  int retInterSection = CheckUnion(head, head2);
  printf("checkunion ret:%d\n", retInterSection);

  int ret = CheckCircle(head);
  printf("check circle:%d\n", ret);

  printf("makecircle \n");
  MakeCircle(head);
  //PList(head);

  retInterSection = CheckUnion(head, head2);
  printf("checkunion2 ret:%d\n", retInterSection);

  ret = CheckCircle(head);
  printf("check circle:%d\n", ret);

  i = FindInList(head, 20);
  printf("\nfind i:%d\n", i);
  
  return 0;
}
开发者ID:ollyblue,项目名称:study,代码行数:56,代码来源:list.cpp

示例9: main

int main()
{
    LNode *la,*lb;
    la=CreateList(la,5);
    lb=CreateList(lb,6);
    Output(la); Output(lb);
    lb=DelInsert(la,lb,2,3,3);
    Output(lb);
    return 0;
}
开发者ID:mjyplusone,项目名称:CppPrimer,代码行数:10,代码来源:main.c

示例10: SumTest

static void SumTest() {
	unsigned int number1[] = { 3, 5, 6 };
	unsigned int number2[] = { 7, 0, 4, 2, 1 };
	IntNode* n1 = CreateList(number1, ARRAY_SIZE(number1));
	IntNode* n2 = CreateList(number2, ARRAY_SIZE(number2));

	IntNode* sum = Sum(n1, n2);
	Asserts::IsTrue(sum != 0);
	
	unsigned int expectedData[] = { 0, 6, 0, 3, 1 };
	std::vector<unsigned int> actual = ToVector(sum);
	Asserts::AreEqual(expectedData, ARRAY_SIZE(expectedData), actual);
}
开发者ID:ppkir,项目名称:InterviewQuestions,代码行数:13,代码来源:Question2_4.cpp

示例11: CreateList

    void CreateList(NodeT* root,NodeL*head)
    { if (root==NULL)
              AddLast(head,"*");
     else
       {
      AddLast(head,root->data);
     CreateList(root->left,head);
     CreateList(root->right,head);
       }



    }
开发者ID:Alecs94,项目名称:DSA-lab,代码行数:13,代码来源:main.cpp

示例12: CreateList

LIST *txtGoKeyAndInsert(U32 textId, char *key, ...)
{
    va_list argument;
    LIST *txtList = CreateList(), *originList = NULL;
    NODE *node;

    va_start(argument, key);

    originList = txtGoKey(textId, key);

    for (node = LIST_HEAD(originList); NODE_SUCC(node); node = NODE_SUCC(node)) {
	U8 i;
	char originLine[256], txtLine[256];

	strcpy(originLine, NODE_NAME(node));
	strcpy(txtLine, NODE_NAME(node));

	for (i = 2; i < strlen(originLine); i++) {
	    if (originLine[i - 2] == '%') {
		sprintf(txtLine, originLine, va_arg(argument, U32));
		i = strlen(originLine) + 1;
	    }
	}

	CreateNode(txtList, 0, txtLine);
    }

    RemoveList(originList);

    return txtList;
}
开发者ID:vcosta,项目名称:derclou,代码行数:31,代码来源:text.c

示例13: TDVASSERT

bool CArticleList::CreateSubsEditorsAllocationsList(int iSubID, const TDVCHAR* pcUnitType, int iNumberOfUnits)
{
	TDVASSERT(pcUnitType != NULL, "CArticleList::CreateSubsEditorsAllocationsList(...) called with NULL pcUnitType");

	CTDVString	sUnitType = pcUnitType;
	sUnitType.MakeLower();

	// if we have an SP then use it, else create a new one
	if (m_pSP == NULL)
	{
		m_pSP = m_InputContext.CreateStoredProcedureObject();
	}
	// if SP is still NULL then must fail
	if (m_pSP == NULL)
	{
		TDVASSERT(false, "Could not create SP in CArticleList::CreateSubsEditorsAllocationsList");
		return false;
	}

	bool bSuccess = true;
	// now proceed with calling the appropriate stored procedure
	bSuccess = bSuccess && m_pSP->FetchSubEditorsAllocationsList(iSubID, sUnitType, iNumberOfUnits);
	// use the generic helper method to create the actual list
	bSuccess = bSuccess && CreateList(100000, 0);
	// now set the list type attribute
	bSuccess = bSuccess && SetAttribute("ARTICLE-LIST", "TYPE", "SUB-ALLOCATIONS");
	bSuccess = bSuccess && SetAttribute("ARTICLE-LIST", "UNIT-TYPE", sUnitType);
	// return success value
	return bSuccess;
}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:30,代码来源:ArticleList.cpp

示例14: CreateList

void
PlaneListWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  const DialogLook &look = UIGlobals::GetDialogLook();
  CreateList(parent, look, rc, GetRowHeight(look));
  UpdateList();
}
开发者ID:j-konopka,项目名称:XCSoar-TE,代码行数:7,代码来源:PlaneListDialog.cpp

示例15: txtInit

/*  public functions - TEXT */
void txtInit(char lang)
{
    char txtListPath[DSK_PATH_MAX];

    if ((txtBase = TCAllocMem(sizeof(*txtBase), 0))) {
	txtBase->tc_Texts = CreateList();
	txtBase->tc_Language = lang;

	dskBuildPathName(DISK_CHECK_FILE, TEXT_DIRECTORY, TXT_LIST, txtListPath);

	if (ReadList(txtBase->tc_Texts, sizeof(struct Text), txtListPath)) {
	    U32 i, nr;

            nr = GetNrOfNodes(txtBase->tc_Texts);

	    for (i=0; i<nr; i++) {
		txtLoad(i);
	    }
	} else {
	    ErrorMsg(No_Mem, ERROR_MODULE_TXT, ERR_TXT_READING_LIST);
	}
    } else {
	ErrorMsg(No_Mem, ERROR_MODULE_TXT, ERR_TXT_FAILED_BASE);
    }
}
开发者ID:vcosta,项目名称:derclou,代码行数:26,代码来源:text.c


注:本文中的CreateList函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。