【发布时间】:2016-07-20 16:29:15
【问题描述】:
我正在执行我的旅行销售计划(不使用 STL)
我知道这不应该给我正确的答案。我正在尝试确保首先正确加载我的矩阵。
谁能看到这里的问题?无论我投入什么,总成本总是为 0。
附带说明:如何从一行中读取多个字符。我实际上需要从位置 6 开始的角色。
//method for getting the minimum cost of the given routes.
void getCost(){
for(int i = 0; i <50; i++){
for(int j = 0; j <50; j++){
if (graph[i][j]>0)
totalCost == totalCost + graph[i][j];
}
}
}
switch (line[0]) {
case 'c':
cCount++;
cout << "Added City: " << line << "\n";
break;
case 'a':
aCount++;
c1 = line[2];
c2 = line[4];
cost = line[6];
cout << "Added Route: " << line << "\n";
graph[c1][c2] == cost;
break;
default:
getCost();
cout << totalCost;
stop = true;
break;
}
【问题讨论】:
标签: c++ arrays matrix traveling-salesman