巧妙的进行VC++6.0代码编制

开发 后端
对于VC++6.0代码正确的编写非常不易,但前提是要深入理解到底什么是VC++6.0代码,及他是怎么运作的,这样就给许多用户带来了便捷。

下面详细说明介绍VC++6.0代码的编制问题,对原来写过的代码做了一点修改,些内容都是一些门户网站和技术论坛找到的,中间可能有不少错误是我没有挑出的,欢迎大家指正。

VC++6.0代码如下:

  1. public:  
  2.  
  3.  
  4.  void addcity(int city);  
  5.  int tabu[iCityCount];  
  6.  void Clear();  
  7.  void UpdateResult();  
  8.  double m_dLength;  
  9.  double m_dShortest;  
  10.  void move();  
  11.  ant();  
  12.  void move2last();  
  13.  
  14.  
  15. };  
  16. void ant::move2last()  
  17. {  
  18.  
  19.  
  20.  int i;  
  21.  for(i=0;i《iCityCount;i++)  
  22.  
  23.   if (AllowedCity[i]==1)  
  24.   {  
  25.    addcity(i);  
  26.    break;  
  27.   }  
  28.  
  29.  
  30. }  
  31.  
  32.  
  33. void ant::Clear()  
  34. {  
  35.  m_dLength=0;  
  36.  int i;  
  37.  for(i=0; i〈iCityCount;i++)  
  38.  
  39.   prob[i]=0;  
  40.   AllowedCity[i]=1;  
  41.  }  
  42.  i=tabu[iCityCount-1];  
  43.  m_iCityCount=0;  
  44.  addcity(i);  
  45. }  
  46. ant::ant()  
  47. {  
  48.  m_dLength=m_dShortest=0;  
  49.  m_iCityCount=0;  
  50.  int i;  
  51.  for(i=0;i〈iCityCount;i++)  
  52.  
  53.   AllowedCity[i]=1;  
  54.   prob[i]=0;  
  55.  }  
  56. }  
  57. void ant::addcity(int city)  
  58. {  
  59.  //add city to tabu;  
  60.  tabu[m_iCityCount]=city;  
  61.  m_iCityCount++;  
  62.  AllowedCity[city]=0;  
  63. }  
  64. int ant::ChooseNextCity()  
  65. {  
  66.  //Update the probability of path selection  
  67.  //select a path from tabu[m_iCityCount-1] to next  
  68.  
  69.  
  70.  int i;  
  71.  int j=10000;  
  72.  double temp=0;  
  73.  int curCity=tabu[m_iCityCount-1];  
  74.  for (i=0;i〈iCityCount;i++)  
  75.  
  76.   if((AllowedCity[i]==1))   
  77.   {  
  78.    temp+=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha);  
  79.   }  
  80.  } 

以上就是VC++6.0代码的举例说明,可以修改循环次数和其他参数。以得到更好的解。使用TSP数据的时候,将前面的一些字符串信息删除,只留下坐标数据。

【编辑推荐】

  1. 如何正确编写C++项目开发编写项目计划书
  2. 对C++库函数进行学习探索总结笔记
  3. 深度演示C++语言的种种高安全性
  4. 详细介绍如何准确无误的编写C++语言
  5. 深度演示C++语言的种种高安全性
责任编辑:chenqingxiang 来源: NET130
相关推荐

2010-01-26 16:47:47

VC++6.0

2010-01-22 18:06:24

C++代码

2009-12-10 16:50:58

Visual Stud

2010-01-26 09:40:23

C++代码

2009-12-08 16:22:06

WCF代码

2009-12-14 10:54:57

VS 2008代码

2010-01-11 15:36:08

C++代码

2009-12-29 11:03:28

ADO代码

2021-12-30 11:30:13

人工智能机器学习技术

2015-07-21 15:35:47

代码总结源码

2020-06-05 14:48:11

零代码低代码开发

2021-11-04 08:06:47

代码编排平台

2010-01-28 15:56:38

VC++ 6.0编译

2009-12-14 16:04:23

MyEclipse 6

2009-03-04 09:52:35

代码契约组件接口

2009-12-18 10:24:28

VS 2010代码

2009-12-17 14:09:03

VS2005代码

2020-06-05 14:43:25

零代码平台企业软件代码

2011-06-10 14:33:38

Qt VC.NET

2009-12-02 09:23:04

Visual Stud
点赞
收藏

51CTO技术栈公众号