浩晨众云网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
下面详细说明介绍VC++6.0代码的编制问题,对原来写过的代码做了一点修改,些内容都是一些门户网站和技术论坛找到的,中间可能有不少错误是我没有挑出的,欢迎大家指正。

站在用户的角度思考问题,与客户深入沟通,找到武进网站设计与武进网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计、网站建设、企业官网、英文网站、手机端网站、网站推广、主机域名、网络空间、企业邮箱。业务覆盖武进地区。
VC++6.0代码如下:
- public:
 - void addcity(int city);
 - int tabu[iCityCount];
 - void Clear();
 - void UpdateResult();
 - double m_dLength;
 - double m_dShortest;
 - void move();
 - ant();
 - void move2last();
 - };
 - void ant::move2last()
 - {
 - int i;
 - for(i=0;i《iCityCount;i++)
 - if (AllowedCity[i]==1)
 - {
 - addcity(i);
 - break;
 - }
 - }
 - void ant::Clear()
 - {
 - m_dLength=0;
 - int i;
 - for(i=0; i〈iCityCount;i++)
 - prob[i]=0;
 - AllowedCity[i]=1;
 - }
 - i=tabu[iCityCount-1];
 - m_iCityCount=0;
 - addcity(i);
 - }
 - ant::ant()
 - {
 - m_dLength=m_dShortest=0;
 - m_iCityCount=0;
 - int i;
 - for(i=0;i〈iCityCount;i++)
 - AllowedCity[i]=1;
 - prob[i]=0;
 - }
 - }
 - void ant::addcity(int city)
 - {
 - //add city to tabu;
 - tabu[m_iCityCount]=city;
 - m_iCityCount++;
 - AllowedCity[city]=0;
 - }
 - int ant::ChooseNextCity()
 - {
 - //Update the probability of path selection
 - //select a path from tabu[m_iCityCount-1] to next
 - int i;
 - int j=10000;
 - double temp=0;
 - int curCity=tabu[m_iCityCount-1];
 - for (i=0;i〈iCityCount;i++)
 - if((AllowedCity[i]==1))
 - {
 - temp+=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha);
 - }
 - }
 
以上就是VC++6.0代码的举例说明,可以修改循环次数和其他参数。以得到更好的解。使用TSP数据的时候,将前面的一些字符串信息删除,只留下坐标数据。
【编辑推荐】