您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ travel函数代码示例

51自学网 2021-06-03 08:58:24
  C++
这篇教程C++ travel函数代码示例写得很实用,希望能帮到您。

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

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

示例1: main

int main(void){	//创建栈并且进行初始化	Stack* ps = create(5);		printf("%s/n",full(ps)?"栈满了":"栈没有满"); // 栈没有满	printf("%s/n",empty(ps)?"栈空了":"栈没有空"); // 栈空了	printf("-----------------------/n");	int i = 0;	for(i = 1; i < 7; i++)	{		push(ps,i*10+i); //元素66入栈失败	}	travel(ps); // 11 22 33 44 55 	printf("出栈的元素是:%d/n",pop(ps));//55	travel(ps);// 11 22 33 44 	printf("出栈的元素是:%d/n",pop(ps));// 44	travel(ps);// 11 22 33 	printf("-------------------/n");	printf("栈顶元素值是:%d/n",peek(ps));// 33	printf("栈中元素的个数是:%d/n",size(ps)); // 3	printf("出栈的元素是:%d/n",pop(ps));// 33	printf("栈顶元素值是:%d/n",peek(ps));// 22	printf("栈中元素的个数是:%d/n",size(ps)); // 2	travel(ps); // 11 22	//销毁栈,数值传递 而不是址传递	destroy(ps);	ps = NULL;	return 0;}
开发者ID:Rovi,项目名称:TarenaCode,代码行数:34,


示例2: main

int main(){	//创建队列并且初始化	Queue queue;	queue.head = NULL;	queue.tail = NULL;	push(&queue, 12);	push(&queue, 22);	push(&queue, 32);	push(&queue, 42);	push(&queue, 52);	push(&queue, 62);	push(&queue, 72);	push(&queue, 82);	push(&queue, 92);	printf("--------------------/n");		travel(&queue);	printf("--------------------/n");		printf("出队的元素是: %d/n", pop(&queue));	printf("%s/n", empty(&queue) ? "队列空" : "队列没空");	printf("%s/n", full(&queue) ? "队列满" : "队列没满");	printf("队列中节点元素个数 :%d/n", size(&queue));	travel(&queue);	printf("--------------------/n");		printf("队首元素: %d/n", get_head(&queue));	printf("队尾元素: %d/n", get_tail(&queue));	printf("--------------------/n");		clean(&queue);	travel(&queue);	return 0;}
开发者ID:Rovi,项目名称:TarenaCode,代码行数:33,


示例3: lowestCommonAncestor

struct TreeNode* lowestCommonAncestor(struct TreeNode* root, struct TreeNode* p, struct TreeNode* q) {	struct TreeNode* ancestorP[MAX] ;	struct TreeNode* ancestorQ[MAX] ;	int countP = 0 ;	int countQ = 0 ;	flag = true ;	travel(root,p,&countP) ; 	for(int i=0;i<=countP;i++){		ancestorP[i] = ancestor[i] ;	} 	flag = true ;	travel(root,q,&countQ) ;	for(int i=0;i<=countQ;i++){		ancestorQ[i] = ancestor[i] ;	}		for(int i=countP;i>=0;i--){		for(int j=countQ;j>=0;j--){			if(ancestorP[i]==ancestorQ[j]){				return ancestorP[i];			}		}			}	return NULL ;}
开发者ID:didiaodanding,项目名称:leetcode,代码行数:30,


示例4: main

int main(){	//创建栈以及进行初始化	Stack stack;	stack.top = NULL;	stack.cnt = 0;		push(&stack, 12);	travel(&stack);		push(&stack, 24);	travel(&stack);		printf("%s/n", full(&stack) ? "满" : "没满");	printf("%s/n", empty(&stack) ? "空" : "没空");	printf("栈顶的元素是: %d/n", peek(&stack)); //bug	printf("栈中元素个数: %d/n", size(&stack));	printf("出栈的元素是: %d", pop(&stack)); //bug	clear(&stack);	return 0;}
开发者ID:Rovi,项目名称:TarenaCode,代码行数:26,


示例5: travel

 void travel(TreeNode * root) {     if(!root) return;     travel(root->left);     ret.push_back(root->val);     travel(root->right); }
开发者ID:Joke-Dk,项目名称:LeetCodeTrain,代码行数:7,


示例6: travel

//1 travelvoid travel(tree** root){   if((*root)==NULL)return;   printf("%d/n",(*root)->data);   travel(&((*root)->left));   travel(&((*root)->right));}
开发者ID:zhengyang3,项目名称:unfinished_code_in_the_past,代码行数:8,


示例7: travel

void travel(int m, int na){	int i,sum=0;	if(m == 1){		putchar('X');		return;	}	for(i=0; sum<na; i++){		sum += a[i]*a[m-1-i];	}	i--;	sum -= a[i]*a[m-1-i];	na -= sum;		if(i>0){		putchar('(');		travel(i,(na-1)/a[m-1-i]+1);		putchar(')');	}	putchar('X');		if(m-1-i>0){		putchar('(');		travel(m-1-i,(na-1)%a[m-1-i]+1);		putchar(')');	}}
开发者ID:ForestDream,项目名称:POJ-Solution-C,代码行数:26,


示例8: main

int main(){	node* headptr;//保存第一个节点的地址	createlist(&headptr);	insert(&headptr, 10, 2);//无效位置,会更正成末尾	insert(&headptr, 20, 0);//20,10	insert(&headptr, 30, 2);//20,10,30	insert(&headptr, 40, 1);//20,40,10,30	insert(&headptr, 50, 8);//无效位置,会更正成末尾	travel(headptr);	printf("剩余%d个数据/n", listsize(headptr));	int n = find(headptr, 10);	printf("查找10在第%d个节点/n", n);	erase(&headptr, n);	travel(headptr);	n = find(headptr, 10);	printf("查找10在第%d个节点/n", n);	erase(&headptr, n);	travel(headptr);	setdata(headptr, 10, 100);	setdata(headptr, 2, 99);	travel(headptr);	clear(&headptr);	printf("剩余%d个数据/n", listsize(headptr));	return 0;}
开发者ID:Jacob-jiangbo,项目名称:my-test,代码行数:26,


示例9: main

int main(void){	//freopen("data.in", "r", stdin);	int n;	scanf("%d", &n);	int** lab=(int**)malloc(n*sizeof(int*));	int** track=(int**)malloc(n*sizeof(int*));	for(int i=0; i<n; i++){		lab[i]=(int*)malloc(n*sizeof(int));		track[i]=(int*)malloc(n*sizeof(int));		memset(lab[i], 0, n*sizeof(int));		memset(track[i], 0, n*sizeof(int));	}	char* string=(char*)malloc((n+1)*sizeof(char));	for(int i=0; i<n; i++){		scanf("%s", string);		for(int j=0; j<n; j++){			char temp;			sscanf(&string[j], "%c", &temp);			lab[i][j]=(temp=='.')?1:0;		}	}	travel(0,0, lab, track, n);	if(!flag){		travel(n-1,n-1, lab, track, n);	}	printf("%d/n", (numb-4)*9);	return 0;}
开发者ID:mingfeisun,项目名称:TimusSolutions,代码行数:28,


示例10: travel

void travel(int i, int j, int** lab, int** track, int n){	track[i][j]=1;	if(i==n-1 && j==n-1){		flag=true;	}		if(i==0 || lab[i-1][j]==0){		numb++;	}	else if(track[i-1][j]==0){		travel(i-1, j, lab, track, n);	}	if(j==n-1 || lab[i][j+1]==0){		numb++;	}	else if(track[i][j+1]!=1){		travel(i, j+1, lab, track, n);	}	if(i==n-1 || lab[i+1][j]==0){		numb++;	}	else if(track[i+1][j]!=1){		travel(i+1, j, lab, track, n);	}	if(j==0 || lab[i][j-1]==0){		numb++;	}	else if(track[i][j-1]!=1){		travel(i, j-1, lab, track, n);	}}
开发者ID:mingfeisun,项目名称:TimusSolutions,代码行数:34,


示例11: travel

 int travel(TreeNode *root, int num) {     if (root == NULL)         return 0;     if (root->left == NULL && root->right == NULL) {         return num * 10 + root->val;     }     int val = root->val;     return travel(root->left, num * 10 + val) + travel(root->right, num * 10 + val); }
开发者ID:jiayinjx,项目名称:leetcode-1,代码行数:9,


示例12: travel

void travel(link p){	if (p == NULL)		return;	printf("%c: counter = %d/n", p->item, p->counter);	travel(p->l);	travel(p->r);}
开发者ID:guolilong2012,项目名称:study,代码行数:9,


示例13: travel

void RBTree::travel(Node *root){	if(root != NIL)	{		travel(root->left);		printf("addr:%x value:%d color:%s parent:%x left:%x right%x/n",			root, root->value, root->color==BLACK?"BLACK":"RED", root->parent, root->left, root->right);		travel(root->right);	}}
开发者ID:wyg031113,项目名称:mycode,代码行数:10,


示例14: travel

    void travel ( TreeNode * root , int current_sum , int sum){	    if (root == NULL ) return ;	    if ( flag ) return;	    if ( ((root->right) == NULL) && ( (root->left) == NULL )){		    if ( sum == (current_sum+root->val) ) flag = true;		    return;	    }	    travel( root->right, current_sum + root->val, sum);    	    travel( root->left, current_sum + root->val, sum);    }
开发者ID:Ruixuan,项目名称:leetcode,代码行数:10,


示例15: travel

 void travel(TreeNode* root, int level, vector<vector<int>> &res ) {     if(!root)         return;     if(level > res.size())         res.push_back(vector<int>());     res[level-1].push_back(root->val);     travel(root->left, left+1, res);     travel(root->right, left+1, res); }
开发者ID:YongHaoWu,项目名称:algorithm_and_datastruct,代码行数:10,


示例16: travel

 void travel(TreeLinkNode* root, int level, vector<vector<TreeLinkNode*> > &nodes){     if(root==NULL) return;          if(level>nodes.size())       nodes.push_back(vector<TreeLinkNode*>());             nodes[level-1].push_back(root);      travel(root->left, level+1, nodes);      travel(root->right, level+1, nodes); }
开发者ID:kakack,项目名称:LeetCode,代码行数:10,


示例17: travel

void travel(struct node* haff, int &hafflen, int h)    // travel a haffman tree and get the haffman code lenth{	h++;//h represents depth of a node	if(haff->value != 0){		haff->codelen = h-1;		hafflen+=haff->fre*haff->codelen;		return;	}	travel(haff->lc, hafflen, h);	travel(haff->rc, hafflen, h);}
开发者ID:fordream,项目名称:C_Workspace,代码行数:11,


示例18: ferry_loop

void ferry_loop(){	/*	Start, check if the south flag is checked, if so	we want to skip doing north and just go straight to south.	Once we get to south we want to check if the flag was set	and if so we want to redeposit passengers before we pick up again.	The same goes for the second loop, we check to see if the north flag	was checked, if so we want to skip the south and go straight back 	to north and pick up the queen there. 	If the flag is set and we return to a bank that we were travelling away	from, we want to re-deposit the passengers currently on the ferry back	onto the shore, then reload them in the correct order (queen first)	*/	if(queen_south_flag!=1)	{		if(queen_north_flag==1)		{			queen_north_flag=0;			//redeposit passengers			redeposit_north();		}		arrive_north();		//Set bank to transit		curr_ferry.curr_bank = 2;		print_proc();		travel();		//We reset the south flag as to not deposit passengers that wanted		//To go to south in the first place, then they get mixed up with north		//Passengers and go back to where they came from		queen_south_flag=0;	}	//if north has queen waiting skip south and go north	if(queen_north_flag!=1)	{		//if south has queen we are already here so just reset flag		if(queen_south_flag==1)		{			queen_south_flag=0;			//reposit passengers			redeposit_south();		}		arrive_south();		//Set bank to transit		curr_ferry.curr_bank = 2;		print_proc();		travel();		queen_north_flag=0;	}}
开发者ID:joshrendek,项目名称:ferry_module,代码行数:54,


示例19: travel

//遍历的递归函数void travel(Node* pn){	if(pn != NULL)	{		//1.遍历左子树,采用递归		travel(pn->left);		//2.遍历根节点		printf("%d ",pn->data);		//3.遍历右子树,采用递归		travel(pn->right);	}}
开发者ID:Rovi,项目名称:TarenaCode,代码行数:13,


示例20: main

int main(int argc, const char *argv[]){    int i;    node_t *head = malloc(sizeof(node_t));    node_t *p = head;    head->id = 1;    for(i = 1; i < 10; i++)        p = create(p, i + 1);    travel(head);    head = tailtohead(head);    travel(head);    return 0;}
开发者ID:ymqqqqdx,项目名称:C_practice,代码行数:13,


示例21: main

int main(int argc, const char *argv[]){    loop *head = NULL,*p;    int i;    srand((unsigned)time(NULL));    head = create(head,rand()%1000);    for(i = 1;i < 100;i++)        p = create((i-1)?p:head,rand()%1000);    travel(head);    putchar('/n');    travel(sequence(head));    return 0;}
开发者ID:ymqqqqdx,项目名称:C_practice,代码行数:13,


示例22: main

int main(void){	btree_pnode t;	create_btree(&t);	travel("先序遍历序列为:",pre_order,t);	travel("先序非递归遍历序列为:",pre_order_un,t);	travel("中序遍历序列为:",mid_order,t);	travel("后序遍历序列为:",post_order,t);	travel("按层遍历序列为:",level_order,t);	return 0;}
开发者ID:kcoewoys,项目名称:work,代码行数:13,


示例23: travel

 void travel(TreeNode *root, int &prev) {     if (!(ok && root)) return;     if (root->left) travel(root->left, prev);     int mid = root->val;     if (!first) {         if (mid <= prev) ok = false;         prev = mid;     } else {         first = false;         prev = mid;     }     if (root->right) travel(root->right, prev); }
开发者ID:tiny656,项目名称:my-leetcode-solutions,代码行数:13,


示例24: main

int main(){	lp p = (lp)NULL;	p=initialize(p);	p = insert(p, 4);	p = insert(p, 6);	p = insert(p, 5);	travel(p);	p = del(p, 6);	travel(p);	p = del(p, 5);	travel(p);	return 0;}
开发者ID:GithubOnePiece,项目名称:DataStructure,代码行数:15,


示例25: travel

 void travel(TreeNode* root, const std::string &path) {     ostringstream oss;     // is leaf     if (root->left == nullptr && root->right == nullptr) {         oss << path << root->val;         allPaths.push_back(oss.str());         return;     }     oss << path << root->val << "->";          if (root->left != nullptr)          travel (root->left, oss.str());     if (root->right != nullptr)         travel (root->right, oss.str()); }
开发者ID:yunyu-Mr,项目名称:myLeetcode,代码行数:15,


示例26: travel

    void travel(TreeNode *root, int sum, int cur, vector<vector<int> > &res, vector<int> rcd) {        if (!root) return;        else {		    cur += root->val;		    rcd.push_back(root->val);            if (cur == sum) {                if (!root->left && !root->right) {                    res.push_back(rcd);                    return;                }      	    }			travel(root->left, sum, cur, res, rcd);			travel(root->right, sum, cur, res, rcd);	    }    }
开发者ID:ichaos,项目名称:leetcode,代码行数:15,


示例27: main

int main(int argc, char **argv) {	int t, count = 0, i, j, k;	S(t);	while(t--){		S(n), S(m);		for(i=0;i<n;n++){			scanf("%s", &forest[i]);			for(j=0;j<m;i++){				if(forest[i][j] == 'M'){					hermione.x = i, hermione.y = j;				}else if(forest[i][j] == '*'){					ext.x = i, ext.y = j;				}			}		}		S(k);		count = travel();		if(count == k){			printf("Impressed/n");		}else{			printf("Oops!/n");		}	}	return 0;}
开发者ID:brijeshb42,项目名称:cpp,代码行数:25,


示例28: main

int main(){		int m, i, n;		int *t = (int *)malloc(2 * sizeof(int));		a = (int *)malloc(2 * sizeof(int));	a[0] = 1, a[1] = 1;	t[0] = 0, t[1] = 1;		while(scanf("%d",&n) != EOF && n != 0){		m = 1;		while(t[m] < n){			//printf("还未达到n/n");			m++;			a = (int *)realloc(a, (m+1)*sizeof(int));			t = (int *)realloc(t, (m+1)*sizeof(int));			a[m] = 0;			for(i=0; i<=m-1; i++){				a[m] += a[i] * a[m-1-i];			}			t[m] = t[m-1] + a[m];			//printf("[a%d]%d/t[t%d]%d/n",m,a[m],m,t[m]);		}		//printf("[%d]%d/n",m,n-t[m-1]);		travel(m,n-t[m-1]);		printf("/n");	}	free(a);	free(t);}
开发者ID:ForestDream,项目名称:POJ-Solution-C,代码行数:31,


示例29: main

int main(void){	struct score tmp, *data;	int i;	srand(getpid());	init();	for (i = 0; i < 1024 * 1024; i++) {		tmp.id = i;		tmp.ch = 100 - i;		//snprintf(tmp.name, NAMESIZE, "stu%d", i);		rand_name(tmp.name, NAMESIZE);		insert(&tmp);	}	//data = search("stu6");	//printf("%d %s %d/n", data->id, data->name, data->ch);	travel();	return 0;}
开发者ID:zyxstar,项目名称:exam_c,代码行数:25,


示例30: main

int main(void) {	//Warning: This recursive implementation is VERY slow for travel(20,20)	//For smaller grids it works better, and is an "elegant" solution	long long count = travel(20,20);	printf("%lld", count);	return 0;}
开发者ID:tprynn,项目名称:Euler,代码行数:7,



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


C++ traveller函数代码示例
C++ trapname函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。