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


C++ printList函数代码示例

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


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

示例1: main

int main() {
	int a;
	head = NULL;
	push( &head, 3);
	push( &head, 2);
	push( &head, 1);
	push( &head, 1);
	checkList();
	printf("Head Node: \n");
	printNode(head);
	printf("List: \n");
	printList(head);
	/* Count Test */
	printf("Count of 1 = %d\n", Count( head, 1 ));
	/* GetNth test */
	printf("Value at node 2 = %d \n", GetNth( head, 2));
	scanf("%d",&a);
}
开发者ID:himz,项目名称:C,代码行数:18,代码来源:ll1.c

示例2: sort

void Ga::selectSurvive(vector<Individual*> &family) {
    sort(family.begin(),family.end(),Individual::Comparator);
    m_Population.push_back(family[0]);
    Util::removeVector(family,0);

    int r=roulette(family);
    m_Population.push_back(family[r]);
    Util::removeVector(family,r);

    for(int i=0; i<family.size(); i++) {
        delete(family[i]);
    }

#ifdef DEBUG
    cout<<"crossover"<<endl;
    printList();
#endif
}
开发者ID:worldcreate,项目名称:rastrigin,代码行数:18,代码来源:Ga.cpp

示例3: main

int main() {
    ListHndl intList;
    intList = newList();

    int data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
/*
 * Integer list testing
 *
 */

    printHeading(" INTEGER LIST ", '#', 80);
    printList(stdout, intList);
    accessorTest("isEmpty", 1, isEmpty(intList));
    
    for(int i = 0; i < 10; i++) {
        insertAtFront(intList, data[i]);
        mutatorTest("%s : data = %d", "insertAtFront", data[i]);
    }

    moveFirst(intList);

    for(int i = 0; i < 5; i++) {
        printList(stdout, intList);
        insertBeforeCurrent(intList, data[i]);
        mutatorTest("insertBeforeCurrent : data = %d", data[i]);
        moveNext(intList);
    }

    accessorTest("isEmpty", 0, isEmpty(intList));
    printList(stdout, intList);

    moveFirst(intList);
    while( !offEnd(intList) ) {
        printList(stdout, intList);
        moveNext(intList);
    }

    moveLast(intList);
    while( !offEnd(intList) ) {
        printList(stdout, intList);
        movePrev(intList);
    }

    makeEmpty(intList);
    mutatorTest("makeEmpty( intList)");

    printList(stdout, intList);
    accessorTest("isEmpty", 1, isEmpty(intList));

    freeList(intList);
    return 0;
}
开发者ID:mwalton,项目名称:algorithms-ADTs,代码行数:52,代码来源:listdr.c

示例4: main

int main(){
	node* head = NULL;
 
    push(&head, 10);
    push(&head, 4);
    push(&head, 15);
    push(&head, 20);
    push(&head, 50);
 
    /* Create a loop for testing */
    head->next->next->next->next->next = head->next->next;
 
    detectAndRemoveLoop(head);
 
    printf("Linked List after removing loop \n");
    printList(head);
	return 0;
}
开发者ID:linearregression,项目名称:geeksforgeeks,代码行数:18,代码来源:25.detect-and-remove-loop-in-a-linked-list.cpp

示例5: printGraph

 void printGraph ( FILE* out, Graph G ) 
 {
  
    if ( G == NULL ) 
    {
       printf ( "Graph Error: printGraph() on NULL graph" );
       exit(1);
    }
    
    int x;
    for(  x = 1; x <= getOrder(G); x++) 
    {
       fprintf(out, "%d: ", x);  
       printList ( out, G->adjacency[x] );
       fprintf(out, "\n");
    }
   
 }
开发者ID:vkarthikthota,项目名称:BFS-C,代码行数:18,代码来源:Graph.c

示例6: main

// insert proper tests here
int main (int argc, const char * argv[]) {
	int start,end;
	printf("input start and end\n");
	scanf("%d %d",&start,&end);

	link list = fromTo (start, end);
	printList (list);
	printf("The sum is %d.\n",sumListItems(list));

	dlink doublelist = doublify(list);
	printDList(doublelist);

	freeList(list);

	freeDList(doublelist);

	return 0;
}
开发者ID:Fuseken,项目名称:code,代码行数:19,代码来源:testLists.c

示例7: shellsort3

void shellsort3(int *a, int n)  
{  
    int i, j, gap;  
  
    for (gap = n / 2; gap > 0; gap /= 2)
    {
        printf("gap = %d\n", gap);
        for (i = gap; i < n; i++)
        {
            for (j = i - gap; j >= 0 && a[j] > a[j + gap]; j -= gap)
            {
                DataSwap(&a[j - 1], &a[j]);
                printDataSwap('i', i, 'j', j);
                printList(a, n);
            }
        }
    }
}
开发者ID:hbdhj,项目名称:c,代码行数:18,代码来源:shell.c

示例8: printGraph

void printGraph(GraphRef g){
	for(int i=0; i<g->numVertices; i++){
		printf("Node %d:\n",  i);
		if(i!=0){
			printf("Parent ");
			printList(g->parent[i]);
		}
		printf("\tColor %d, Dist %d", g->color[i], g->distance[i]); 
		printf("\tEdges:");
		ListRef index = g->vertices[i];
		moveFirst(index);
		while(!offEnd(index)){
			printf("%d, ",getCurrent(index));	
		moveNext(index);
		}
		 
	}
} 
开发者ID:smorad,项目名称:cmps101,代码行数:18,代码来源:graph.c

示例9: main

int main(){
  int i=0;
  char name[50];
  int roll_no;
  node *first=NULL;


  for(i=0;i<5;i++){
    printf("Enter Name:");
    readline(name,50);
    printf("Enter Roll No:");
    scanf("%d",&roll_no);
    
    //    first=addToBegining(first,name,roll_no);
    first=addToEnd(first,name,roll_no);
  }
  printList(first);
}
开发者ID:reubencornel,项目名称:webpage,代码行数:18,代码来源:linklist2.c

示例10: main

int main() {
  int a[N], b[N], i;

  for (i = 0; i< N; i++) {
    a[i] = i;
    b[i] = 0;
  }
  
  veccpy(a, b, N);

  if (memcmp(a, b, N * sizeof (int)) != 0) {
    printList((int *)a, (int *)b, N);
    printf ("Vector copy C case - Failed \n");
  } else {
    printf ("Vector copy C case - Passed \n");
  }
  return 0;
} 
开发者ID:yyzreal,项目名称:HSA-OpenMP-GCC-AMD,代码行数:18,代码来源:omp_veccopy.c

示例11: main

int main()
{
    struct ListNode * t1[4];
    for(int i = 0; i< 4; i++){
        t1[i] = malloc(sizeof(struct ListNode));
    }
    t1[0]->val = 1;
    t1[1]->val = 2;
    t1[2]->val = 2;
    t1[3]->val = 5;
    t1[0]->next = t1[1];
    t1[1]->next = t1[2];
    t1[2]->next = t1[3];
    t1[3]->next = NULL;
    struct ListNode * hhh = deleteDuplicates(t1[0]);
    printList(hhh);

}
开发者ID:xiaolongnk,项目名称:Alglib,代码行数:18,代码来源:ag_83.c

示例12: output

void Function::outputFile(string filename)
{
    ofstream output(filename);
    if (output.is_open() == true)
    {
        output << "var code = {\"type\":\"function\", \"code\":\"";
        output << addBackslashes(statements.statement);
        output << "\", \"inner\":[";
        output << printList(statements.children);
        output << "]};";

        output.close();
    }
    else
    {
        //error
    }
}
开发者ID:Grain,项目名称:see-code-parser,代码行数:18,代码来源:function.cpp

示例13: inputCommand

static void inputCommand(void)
{
	char command[20];

	printf("Type 'help' to see help\n\n");

	while (true) {
		fgets(command, 20, stdin);

		if (command[strlen(command) - 1] == '\n') {
			command[strlen(command) - 1] = '\0';
		}

		if (_stricmp(command, "about") == 0) {
			printAbout();
		} else if (_stricmp(command, "help") == 0) {
			printHelp();
		} else if (_stricmp(command, "log on") == 0) {
			g_RPCServer.SetLogOn(true);
		} else if (_stricmp(command, "log off") == 0) {
			g_RPCServer.SetLogOn(false);
		} else if (_stricmp(command, "list") == 0) {
			printList();
		} else if (_stricmp(command, "quit") == 0) {
			if (g_MountProg.GetMountNumber() == 0) {
				break;
			} else {
				printConfirmQuit();
				fgets(command, 20, stdin);

				if (command[0] == 'y' || command[0] == 'Y') {
					break;
				}
			}
		} else if (_stricmp(command, "refresh") == 0) {
			g_MountProg.Refresh();
		} else if (_stricmp(command, "reset") == 0) {
			g_RPCServer.Set(PROG_NFS, NULL);
		} else if (strcmp(command, "") != 0) {
			printf("Unknown command: '%s'\n", command);
			printf("Type 'help' to see help\n");
		}
	}
}
开发者ID:realshadow,项目名称:winnfsd,代码行数:44,代码来源:winnfsd.cpp

示例14: main

void main(void)
{
	int i = 1;
	int x = 0;
	List1Element * head = createList();
	intro();
	scanf ("%d", &i);
	while (i)
	{
		switch (i)
		{
			//case 0:
			//	delList(head);
			//	break;
			case 1 :
				printf("enter the value\n");
				scanf("%d", &x);
				insertEl (head, x);
				break;
			case 2 :
				if (isEmpty(head))
					printf("sorry it seems to be nothing here\n");
				else
					printf("%d\n", getMin(head));
				break;
			case 3:
				if (isEmpty(head))
					printf("sorry it seems to be nothing here\n");
				else
					printList(head);
					printf("\n");
				break;
			default:
				printf("no no no, you're doing it wrong!\n");
		}
		if (i)
		{
			intro();
			scanf ("%d", &i);
		}
	}
	delList(head);
	delete head;
}
开发者ID:esengie,项目名称:Semester1,代码行数:44,代码来源:task3.cpp

示例15: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	printf("0 - exit\n");
    printf("1 - add value to sorted list\n");
    printf("2 - remove value from list\n");
    printf("3 - print list\n");

	IntList *head = newList(-1);

	while(true)
	{
		printf("Input command:\n");
		int command = 0;
		scanf("%d", &command);
		int val = 0;
		switch (command)
		{
			case 0:
				deleteList(head);
				return 0;
			case 1:
				printf("Input value:\n");
				
				scanf("%d", &val);
				addToSortedList(head, val);
				break;
			case 2:
				printf("Input value:\n");
				
				scanf("%d", &val);
				removeValue(head, val);
				break;
			case 3:
				printList(head);
				break;
		};

	}
	
	deleteList(head);

	scanf("%*s");
	return 0;
}
开发者ID:MrKuznetsov,项目名称:hw-cpp,代码行数:44,代码来源:Task3.cpp


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