在我的公共文件夹中,我有 index.html 文件,我的路由处理程序是这样的
router.get('/', function (req, res, next) {
// res.send('index.html');
if (req.user)
res.redirect('home');
else
res.redirect('login');
});
Run Code Online (Sandbox Code Playgroud)
如您所见,我已经注释掉了 index.html 文件的服务,但 nodejs 仍然从公共目录提供 index.html,而不是重定向到 home 或登录。但是,如果我删除/重命名 index.html 文件,则它可以正常工作。
那么如何配置 nodejs 以便它根据请求调用路由处理程序,而不是服务索引文件?
如何从函数返回一个整数和一个向量.在c ++ 11中,我可以使用元组.但我必须使用C++ 98标准.
问题是这样的,
int myfunction(parameter 1,parameter 2)
{
vector<int> created_here;
//do something with created here
return int & created_here both
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点.顺便说一下,我必须递归地使用我的函数.所以我想到了这样的方式,
int n;
vector<int> A;
int myfunction(int pos,int mask_cities,vector<int> &A)
{
if(mask = (1<<n)-1)
return 0;
vector<int> created_here;
int ans = 999999;
for(int i=0;i<n;++i){
int tmp = myfunction(pos+1,mask|1<<i,created_here);
if(tmp<ans){
A = created_here;
ans = tmp;
}
}
return ans;
}
Run Code Online (Sandbox Code Playgroud)
这会有用吗?或者有一个更好的解决方案.顺便说一句,我的实际问题是找到旅行商问题的解决方案.这应该澄清我的需求
在订单统计树中,节点的等级是多少?
是由它给出的
rank = x.left.size + 1
Run Code Online (Sandbox Code Playgroud)
还是通过这个功能?
OS-RANK(T, x)
{
r = left.size + 1
y = x
while (y != T.root)
{
if (y == y.p.right) {
r = r + y.p.left.size + 1
}
}
return r
}
Run Code Online (Sandbox Code Playgroud)
我真的很困惑,因为我认为它应该是简单的x.left.size + 1,因为那应该是x树的顺序树行走的位置.
我有这样的网格
000000000
0AAA00000
0AA000000
0AAA00000
000000000
000000000
000000B00
00000BBB0
00000BBBB
Run Code Online (Sandbox Code Playgroud)
现在如何使用bfs找到从A到B的最短路径?A和A之间的旅行费用为0,A-0或0-B或0-0为1.我已经尝试在每个A上单独应用bfs并采用最小值.但这似乎不起作用.还有其他办法吗?
我想将2D数组memset为0.这是我的代码..但它总是给我seg错误;
bool **visited=new bool*[m];
for(int i=0;i<m;++i)
visited[i] = new bool[m];
Run Code Online (Sandbox Code Playgroud)
我曾尝试memset(visited, 0, sizeof(visited[0][0]) * m * m);和memset(visited, 0, sizeof visited);,但nonw的这部作品,并给了我段错误.我怎么做?