• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ printList函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: if

string Function::printList(vector<struct node> sequence)    //to JSON
{
    string output;

    for (unsigned int i = 0; i < sequence.size(); ++i)
    {
        output.append("{");
        if (sequence.at(i).children.size() > 0)
        {
            string type;
            if (sequence.at(i).statement.at(0) == 'i')
                type = "if";
            else if (sequence.at(i).statement.at(0) == 'f')
                type = "for";
            else if (sequence.at(i).statement.at(0) == 'w')
                type = "while";
            else if (sequence.at(i).statement.at(0) == 'd')
                type = "do";
            else if (sequence.at(i).statement.at(0) == 'e' && sequence.at(i).statement.size() > 6)
                type = "else if";
            else if (sequence.at(i).statement.at(0) == 'e')
                type = "else";
            output.append("\"type\":\"");
            output.append(type);
            output.append("\", \"code\":\"");
            output.append(addBackslashes(sequence.at(i).statement));
            output.append("\", \"inner\":[");
            output.append(printList(sequence.at(i).children));
            output.append("]");
        }
        else
        {
            output.append("\"type\":\"statement\", \"code\":\"");
            output.append(addBackslashes(sequence.at(i).statement));
            output.append("\", \"inner\":[]");
        }

        output.append("},");
    }

    output.erase(output.end() - 1, output.end());

    return output;
}
开发者ID:Grain,项目名称:see-code-parser,代码行数:44,代码来源:function.cpp


示例17: main

int main (int argc, const char * argv[])
{
  	TYPE task1, task2, task3, task4, task5, task6, task7, task8, task9, task10;
	DynArr mainList;
	int i;
	initDynArr(&mainList, 10);

	/* create tasks */
	task1 = createTask(9, "task 1");
	task2 = createTask(3, "task 2");
	task3 = createTask(2, "task 3");
	task4 = createTask(4, "task 4");
	task5 = createTask(5, "task 5");
	task6 = createTask(7, "task 6");
	task7 = createTask(8, "task 7");
	task8 = createTask(6, "task 8");
	task9 = createTask(1, "task 9");
	task10 = createTask(0, "task 10");
	
	/* add tasks to the dynamic array */
	addDynArr(&mainList, task1);
	addDynArr(&mainList, task2);
	addDynArr(&mainList, task3);
	addDynArr(&mainList, task4);
	addDynArr(&mainList, task5);
	addDynArr(&mainList, task6);
	addDynArr(&mainList, task7);
	addDynArr(&mainList, task8);
	addDynArr(&mainList, task9);
	addDynArr(&mainList, task10);

	/* sort tasks */
	sortHeap(&mainList);

	/* print sorted tasks from the dynamic array */
	for (i = 0; i < mainList.size; i++)
	{
	  	printf("%d\n", mainList.data[i].priority);
	}
    
    printList(&mainList);

	return 0;
}
开发者ID:vb3,项目名称:homework,代码行数:44,代码来源:main2.c


示例18: main

int main()
{
	int i,size=15;
	ElementList E;
	Element e1;
	e1.id=2000;
	e1.regstatus=0;
	for(i=0;i<size;i++)
	{
			E[i].id=i;
			E[i].regstatus=(i%3); //0= Success, 1 = Conflict, 2 = Deny
	}
	// R containing All (size number) registered student records
	ListHead ks, kd, kc;
	ks=createList();
	kd=createList();
	kc=createList();	 				
	for (i = 0; i < size; i++) {
		if  (E[i].regstatus == 0) {
	  		insertAtTail (E[i], ks);
		} else if  (E[i].regstatus == 1) {
			insertAtHead (E[i], kc);
		} else {
			insertAtHead (E[i], kd);
		}
	}
	printf("\n\nSUCCESS LIST\n");
	printList(ks);

	printf("\n\nCONFLICT LIST\n");
	printList(kc);

	printf("\n\nDENY LIST\n");
	printList(kd);


	deleteFromHead(ks);
	deleteFromTail(kc);
	deleteFromHead(kd);

	printf("\n\nSUCCESS LIST After Deletion\n");
	printList(ks);

	printf("\n\nCONFLICT LIST After Deletion\n");
	printList(kc);

	printf("\n\nDENY LIST After Deletion\n");
	printList(kd);
	

}
开发者ID:f2008700,项目名称:BITS,代码行数:51,代码来源:main.c


示例19: main

int main(int argc, char** argv)
{
  //Linked list header
  head = Malloc(sizeof(struct ListNode));
  head->data = -1; //Negative one for header data (start appending at zero in threads)
  head->prev = NULL;
  head->next = NULL;
    
  //Spawn some threads to insert into the linked list
  pthread_t threads[NUM_THREADS];
  int t, rc;
  
  for(t=0; t<NUM_THREADS; t++)
  {
      rc = pthread_create(&threads[t], NULL, doAppend, (void *)t);
      if (rc)
      {
         printf("ERROR: return code from pthread_create() is %d\n", rc);
         exit(-1);
      }
   }
   
   //Wait for threads to finish
   void * status;
   for(t=0; t<NUM_THREADS; t++) 
   {
      rc = pthread_join(threads[t], &status);
      if (rc) 
      {
         printf("ERROR: return code from pthread_join() is %d\n", rc);
         exit(-1);
      }
      //printf("Main: completed join with thread %d having a status of %d\n",t,status);
   }
   
   //Print the list after all threads are done
   printList(head);
   
  
  
  //Exit main properly
  pthread_exit(NULL);
}
开发者ID:JulianKemmerer,项目名称:Drexel-ECEC353,代码行数:43,代码来源:part1unsafe.c


示例20: partition

static int partition(void *data, int esize, int i, int k, int (*compare)(const void *key1, const void *key2))
{
    char *a = data;
    void *pval, *temp;
    int r[3];
    if ((pval = malloc(esize)) == NULL) {
        return -1;
    }
    if ((temp = malloc(esize)) == NULL) {
        free(pval);
        return -1;
    }
    r[0] = (rand() % (k - i + 1) + i);
    r[1] = (rand() % (k - i + 1) + i);
    r[2] = (rand() % (k - i + 1) + i);
    printList(r, 3);
    issort(r, 3, sizeof(int), compare_int);
    memcpy(pval, &a[r[1] * esize], esize);
    i--;
    k++;
    while (1) {
        do {
            k--;
        } while (compare(&a[k * esize], pval) > 0);
        
        do {
            i++;
        } while (compare(&a[i * esize], pval) < 0);
        
        if (i >= k) {
            break;
        }
        else
        {
            memcpy(temp, &a[i *esize], esize);
            memcpy(&a[i * esize], &a[k * esize], esize);
            memcpy(&a[k * esize], temp, esize);
        }
    }
    free(pval);
    free(temp);
    return k;
}
开发者ID:BaconTimes,项目名称:C_Learning,代码行数:43,代码来源:qksort.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ printMatrix函数代码示例发布时间:2022-05-30
下一篇:
C++ printLine函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap