Giter Club home page Giter Club logo

competition's Introduction

Starting with an interesting project , let's make everything possible

Anurag's GitHub stats

competition's People

Contributors

unickcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jyeeee

competition's Issues

排序

关于分数排序两种方案

  • 用数组t[101]统计相同成绩出现的人数,下标为对应的分数(适用于大多数情况)
  • 先sort排序后,一一遍历,若成绩与前一位相同,则名词一致,否则名次为下标+1(适用于在不破坏输入时的顺序)

树的基本操作

已知后序和先序,进行建树

int build(int l1,int r1,int l2,int r2)
{
	if(l1>r1) return 0;
	int node=post_order[r2];
	int p=l1;
	while(in_order[p]!=node) p++;
	ltree[node]=build(l1,p-1,l2,l2+p-l1-1);
	rtree[node]=build(p+1,r1,l2+p-l1,r2-1);
	return node;
}

对树进行层次遍历(BFS版)

void bfs(int root)
{//广度搜索进行层次遍历
	queue<int> q;
	q.push(root);
	while(!q.empty())
	{
		int u=q.front();q.pop();
		printf("%d ",u);
		if(ltree[u]) q.push(ltree[u]);
		if(rtree[u]) q.push(rtree[u]);
	}
}

对树进行先序,中序,后序遍历

void proOrder(int node)
{//先序遍历
	printf("%d ",node);
	if(ltree[node]) pro(ltree[node]);
	if(rtree[node]) pro(rtree[node]);
}

void inOrder(int node)
{//中序遍历
	if(ltree[node]) pro(ltree[node]);
	printf("%d ",node);
	if(rtree[node]) pro(rtree[node]);
}

void postOrder(int node)
{//后序遍历
	if(ltree[node]) pro(ltree[node]);
	if(rtree[node]) pro(rtree[node]);
	printf("%d ",node);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.