用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c++代码库

关键路径

2017-12-15 作者: 柯侧耳倾听者举报

[c++]代码库

#include <stdio.h>
#define NODES 6
int graph[6][6]={
	{0,0,1,1,0,0},
	{0,0,0,0,1,0},
	{0,0,0,0,0,1},
	{0,0,0,0,0,1},
	{0,0,0,0,0,1},
	{0,0,0,0,0,0},};
int result[6];
int i=0;

void setline(int line) {
	for (int i=0;i<NODES;i++) { 
		graph[line][i]=0;
	}
}

int judgecol(int col) {
	for (int i=0;i<NODES;i++) {
		if (graph[i][col]) {
			return 0;
		}
	}
	return 1;
}

int main() {
	int isdeleted[NODES]={0,0,0,0,0,0};
	while (!isdeleted[0]||!isdeleted[1]||!isdeleted[2]||!isdeleted[3]||!isdeleted[4]||!isdeleted[5]) {
		int node;
		if (judgecol(0)&&!isdeleted[0]) node=0;
		if (judgecol(1)&&!isdeleted[1]) node=1;
		if (judgecol(2)&&!isdeleted[2]) node=2;
		if (judgecol(3)&&!isdeleted[3]) node=3;
		if (judgecol(4)&&!isdeleted[4]) node=4;
		if (judgecol(5)&&!isdeleted[5]) node=5;
		setline(node);
		isdeleted[node]=1;
		printf("%d ",node+1);
		//if (judgecol(0)&&judgecol(1)&&judgecol(2)&&judgecol(3)&&judgecol(4)&&judgecol(5)) break;
	}
	return 0;
}


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...