zoukankan      html  css  js  c++  java
  • 遗传算法入门(转载)

    优化算法入门系列文章目录(更新中):

      1. 模拟退火算法

      2. 遗传算法

      遗传算法 ( GA , Genetic Algorithm ) ,也称进化算法 。 遗传算法是受达尔文的进化论的启发,借鉴生物进化过程而提出的一种启发式搜索算法。因此在介绍遗传算法前有必要简单的介绍生物进化知识。

    一.进化论知识 

      作为遗传算法生物背景的介绍,下面内容了解即可:

      种群(Population)生物的进化以群体的形式进行,这样的一个群体称为种群。

      个体:组成种群的单个生物。

      基因 ( Gene ) 一个遗传因子。 

      染色体 ( Chromosome ) :包含一组的基因。

      生存竞争,适者生存:对环境适应度高的、牛B的个体参与繁殖的机会比较多,后代就会越来越多。适应度低的个体参与繁殖的机会比较少,后代就会越来越少。

      遗传与变异:新个体会遗传父母双方各一部分的基因,同时有一定的概率发生基因变异。

      简单说来就是:繁殖过程,会发生基因交叉( Crossover ) ,基因突变 ( Mutation ) ,适应度( Fitness )低的个体会被逐步淘汰,而适应度高的个体会越来越多。那么经过N代的自然选择后,保存下来的个体都是适应度很高的,其中很可能包含史上产生的适应度最高 的那个个体。

    二.遗传算法思想 

      借鉴生物进化论,遗传算法将要解决的问题模拟成一个生物进化的过程,通过复制、交叉、突变等操作产生下一代的解,并逐步淘汰掉适应度函数值低的解,增加适应度函数值高的解。这样进化N代后就很有可能会进化出适应度函数值很高的个体。

      举个例子,使用遗传算法解决“0-1背包问题”的思路:0-1背包的解可以编 码为一串0-1字符串(0:不取,1:取) ;首先,随机产生M个0-1字符串,然后评价这些0-1字符串作为0-1背包问题的解的优劣;然后,随机选择一些字符串通过交叉、突变等操作产生下一代的 M个字符串,而且较优的解被选中的概率要比较高。这样经过G代的进化后就可能会产生出0-1背包问题的一个“近似最优解”。

      编码:需要将问题的解编码成字符串的形式才能使用遗传算法。最简单的一种编码方式是二进制编码,即将问题的解编码成二进制位数组的形式。例如,问题的解是整数,那么可以将其编码成二进制位数组的形式。将0-1字符串作为0-1背包问题的解就属于二进制编码。

      遗传算法有3个最基本的操作:选择,交叉,变异。

      选择:选择一些染色体来产生下一代。一种常用的选择策略是 “比例选择”, 也就是个体被选中的概率与其适应度函数值成正比。假设群体的个体总数是M,那么那么一个体Xi被选中的概率为f(Xi)/( f(X1) + f(X2) + …….. + f(Xn) ) 。比例选择实现算法就是所谓的“轮盘赌算法”( Roulette Wheel Selection ) ,轮盘赌算法的一个简单的实现如下:

     

    复制代码
    轮盘赌算法
    /*
    * 按设定的概率,随机选中一个个体
    * P[i]表示第i个个体被选中的概率
    */
    int RWS()
    {
    m =0;
    r =Random(0,1); //r为0至1的随机数
    for(i=1;i<=N; i++)
    {
    /* 产生的随机数在m~m+P[i]间则认为选中了i
    * 因此i被选中的概率是P[i]
    */
    m = m + P[i];
    if(r<=m) return i;
    }
    }
    复制代码

     

    交叉(Crossover):2条染色体交换部分基因,来构造下一代的2条新的染色体。例如:

    交叉前:

    00000|011100000000|10000

    11100|000001111110|00101

    交叉后:

    00000|000001111110|10000

    11100|011100000000|00101

    染色体交叉是以一定的概率发生的,这个概率记为Pc 。

     

    变异(Mutation):在繁殖过程,新产生的染色体中的基因会以一定的概率出错,称为变异。变异发生的概率记为Pm 。例如:

    变异前:

    000001110000000010000

    变异后:

    000001110000100010000

     

    适应度函数 ( Fitness Function ): 用于评价某个染色体的适应度,用f(x)表示。有时需要区分染色体的适应度函数与问题的目标函数。例如:0-1背包问题的目标函数是所取得物品价值,但将 物品价值作为染色体的适应度函数可能并不一定适合。适应度函数与目标函数是正相关的,可对目标函数作一些变形来得到适应度函数。

     

     

    三.基本遗传算法的伪代码 

     

     

    复制代码
    基本遗传算法伪代码
    /*
    * Pc:交叉发生的概率
    * Pm:变异发生的概率
    * M:种群规模
    * G:终止进化的代数
    * Tf:进化产生的任何一个个体的适应度函数超过Tf,则可以终止进化过程
    */
    初始化Pm,Pc,M,G,Tf等参数。随机产生第一代种群Pop

    do
    {
      计算种群Pop中每一个体的适应度F(i)。
      初始化空种群newPop
      do
      {
        根据适应度以比例选择算法从种群Pop中选出2个个体
        if ( random ( 0 , 1 ) < Pc )
        {
          对2个个体按交叉概率Pc执行交叉操作
        }
        if ( random ( 0 , 1 ) < Pm )
        {
          对2个个体按变异概率Pm执行变异操作
        }
    将2个新个体加入种群newPop中
    } until ( M个子代被创建 )
    用newPop取代Pop
    }until ( 任何染色体得分超过Tf, 或繁殖代数超过G )
     
    复制代码

     

     

    四.基本遗传算法优化 

       下面的方法可优化遗传算法的性能。

       精英主义(Elitist Strategy)选择:是基本遗传算法的一种优化。为了防止进化过程中产生的最优解被交叉和变异所破坏,可以将每一代中的最优解原封不动的复制到下一代中。

       插入操作:可在3个基本操作的基础上增加一个插入操作。插入操作将染色体中的某个随机的片段移位到另一个随机的位置。

     

     

    五. 使用AForge.Genetic解决TSP问题

      AForge.NET是一个C#实现的面向人工智能、计算机视觉等领域的开源架构。AForge.NET中包含有一个遗传算法的类库。

      AForge.NET主页:http://www.aforgenet.com/

      AForge.NET代码下载:http://code.google.com/p/aforge/

      介绍一下AForge的遗传算法用法吧。AForge.Genetic的类结构如下:


    图1. AForge.Genetic的类图

       下面用AForge.Genetic写个解决TSP问题的最简单实例。测试数据集采用网上流传的中国31个省会城市的坐标:

     

    复制代码
    13042312
    36391315
    41772244
    37121399
    34881535
    33261556
    32381229
    41961004
    4312790
    4386570
    30071970
    25621756
    27881491
    23811676
    1332695
    37151678
    39182179
    40612370
    37802212
    36762578
    40292838
    42632931
    34291908
    35072367
    33942643
    34393201
    29353240
    31403550
    25452357
    27782826
    23702975
    复制代码

    操作过程:

       (1) 下载AForge.NET类库,网址:http://code.google.com/p/aforge/downloads/list

       (2) 创建C#空项目GenticTSP。然后在AForge目录下找到AForge.dll和AForge.Genetic.dll,将其拷贝到 TestTSP项目的bin/Debug目录下。再通过“Add Reference...”将这两个DLL添加到工程。

       (3) 将31个城市坐标数据保存为bin/Debug/Data.txt 。

       (4) 添加TSPFitnessFunction.cs,加入如下代码:

     

    复制代码
    TSPFitnessFunction类
    using System;
    using AForge.Genetic;

    namespace GenticTSP
    {
    ///<summary>
    /// Fitness function for TSP task (Travaling Salasman Problem)
    ///</summary>
    publicclass TSPFitnessFunction : IFitnessFunction
    {
    // map
    privateint[,] map =null;

    // Constructor
    public TSPFitnessFunction(int[,] map)
    {
    this.map = map;
    }

    ///<summary>
    /// Evaluate chromosome - calculates its fitness value
    ///</summary>
    publicdouble Evaluate(IChromosome chromosome)
    {
    return1/ (PathLength(chromosome) +1);
    }

    ///<summary>
    /// Translate genotype to phenotype
    ///</summary>
    publicobject Translate(IChromosome chromosome)
    {
    return chromosome.ToString();
    }

    ///<summary>
    /// Calculate path length represented by the specified chromosome
    ///</summary>
    publicdouble PathLength(IChromosome chromosome)
    {
    // salesman path
    ushort[] path = ((PermutationChromosome)chromosome).Value;

    // check path size
    if (path.Length != map.GetLength(0))
    {
    thrownew ArgumentException("Invalid path specified - not all cities are visited");
    }

    // path length
    int prev = path[0];
    int curr = path[path.Length -1];

    // calculate distance between the last and the first city
    double dx = map[curr, 0] - map[prev, 0];
    double dy = map[curr, 1] - map[prev, 1];
    double pathLength = Math.Sqrt(dx * dx + dy * dy);

    // calculate the path length from the first city to the last
    for (int i =1, n = path.Length; i < n; i++)
    {
    // get current city
    curr = path[i];

    // calculate distance
    dx = map[curr, 0] - map[prev, 0];
    dy = map[curr, 1] - map[prev, 1];
    pathLength += Math.Sqrt(dx * dx + dy * dy);// put current city as previousprev = curr;}return pathLength;}}}
    复制代码

       (5) 添加GenticTSP.cs,加入如下代码:

     

    复制代码
    GenticTSP类
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;

    using AForge;
    using AForge.Genetic;


    namespace GenticTSP
    {
    class GenticTSP
    {

    staticvoid Main()
    {
    StreamReader reader =new StreamReader("Data.txt");

    int citiesCount =31; //城市数

    int[,] map =newint[citiesCount, 2];

    for (int i =0; i < citiesCount; i++)
    {
    string value = reader.ReadLine();
    string[] temp = value.Split('');
    map[i, 0] =int.Parse(temp[0]); //读取城市坐标
    map[i, 1] =int.Parse(temp[1]);
    }

    // create fitness function
    TSPFitnessFunction fitnessFunction =new TSPFitnessFunction(map);

    int populationSize = 1000; //种群最大规模

    /*
    * 0:EliteSelection算法
    * 1:RankSelection算法
    * 其他:RouletteWheelSelection 算法
    * */
    int selectionMethod =0;

    // create population
    Population population =new Population(populationSize,
    new PermutationChromosome(citiesCount),
    fitnessFunction,
    (selectionMethod ==0) ? (ISelectionMethod)new EliteSelection() :
    (selectionMethod ==1) ? (ISelectionMethod)new RankSelection() :
    (ISelectionMethod)new RouletteWheelSelection()
    );

    // iterations
    int iter =1;
    int iterations =5000; //迭代最大周期

    // loop
    while (iter < iterations)
    {
    // run one epoch of genetic algorithm
    population.RunEpoch();

    // increase current iteration
    iter++;
    }

    System.Console.WriteLine("遍历路径是: {0}", ((PermutationChromosome)population.BestChromosome).ToString());
    System.Console.WriteLine("总路程是:{0}", fitnessFunction.PathLength(population.BestChromosome));
    System.Console.Read();

    }
    }
    }
    复制代码

     

     

     

    网上据称这组TSP数据的最好的结果是 15404 ,上面的程序我刚才试了几次最好一次算出了15402.341,但是最差的时候也跑出了大于16000的结果。

    我这还有一个版本,设置种群规模为1000,迭代5000次可以算出15408.508这个结果。源代码在文章最后可以下载。

     

    总结一下使用AForge.Genetic解决问题的一般步骤:

       (1) 定义适应函数类,需要实现IFitnessFunction接口

       (2) 选定种群规模、使用的选择算法、染色体种类等参数,创建种群population

       (3)设定迭代的最大次数,使用RunEpoch开始计算

     

    本文源代码下载

     

    例子二:用遗传算法求解函数最大值:

     

     

      1 /***********************************************************
      2 **             人工智能--遗传算法
      3 **
      4 **        求解f (x) = x2 的最大值,x∈ [0,31]
      5 **      
      6 **        author: CS0921 WTU
      7 **                                                        
      8 /**********************************************************/
      9 
     10 #include <stdio.h>    
     11 #include <string.h>
     12 #include <stdlib.h>
     13 #include <time.h>
     14 
     15 #define TEST         1         //0:屏蔽所有的调试信息    1:开启所有的调试信息
     16 #define TEST_FLAG    2         //1:测试randCreatePop函数 2:测试selection函数
     17 //3.测试crossover函数     4.测试mutation函数
     18 
     19 #define CROSS_RATE     0.5       //变异率(mutation rate)取值范围一般为0.4~0.99
     20 #define MUT_RATE     0.09      //变异率(mutation rate)取值范围一般为0.0001~0.1
     21 #define ITER_NUM     1000         //迭代次数(iteration number)
     22 #define POP_NUM      4         //初始化种群的个数
     23 #define GENE_NUM     5         //基因的位数个数
     24 #define FUN_EXP(x)   ((x)*(x)) //函数表达式
     25 
     26 typedef unsigned int UINT;
     27 
     28 //染色体的数据结构
     29 typedef struct{                        
     30     char geneBit[GENE_NUM]; //基因位(gene bit)表示方式
     31     UINT fitValue;          //适应值(fittness value)(衡量个体的优劣)
     32 }Chromosome;
     33 
     34 void randCreatePop(Chromosome *);             //随机创建初始群体
     35 void selection(Chromosome *);                 //选择(Selection):根据适应度选择优良个体(最优解)
     36 void crossover(Chromosome *);                 //交叉(Crossover):染色体的片断(基因)进行交换
     37 void mutation(Chromosome *);                 //变异(Mutation) :随机改变染色体片断(基因)的值
     38 void updatePop(Chromosome *, Chromosome *);//更新种群
     39 void printResult(Chromosome *);             //打印结果(当x为何值时,f(x)最大)
     40 UINT calcFitValue(UINT);                     //计算染色体的适应度值
     41 UINT binToDec(Chromosome);                     //将类似二进制的基因位转化为十进制
     42 void test(Chromosome *);                     //测试函数
     43 
     44 
     45 int main(int argc, char *argv[])                                  
     46 {
     47     int count;                    // 记录迭代次数
     48     Chromosome curPop[POP_NUM];   // 初始种群
     49     Chromosome nextPop[POP_NUM];  // 更新后种群
     50 
     51     //随机创建初始群体
     52     randCreatePop(curPop);
     53 
     54     //开始迭代 
     55     for(count=1; count<(ITER_NUM+1); count++)
     56     {
     57         updatePop(curPop, nextPop); // 更新种群 
     58         selection(nextPop);           // 挑选优秀个体 
     59         crossover(nextPop);           // 交叉得到新个体 
     60         mutation(nextPop);           // 变异得到新个体 
     61         updatePop(nextPop, curPop); // 种群更替
     62 
     63         printf("
    第%d代迭代的结果:
    ", count); // 输出当前迭代次数,即种群的代数
     64         test(curPop);               //输出结果
     65     }//迭代结束 
     66 
     67     printResult(curPop); //打印结果(当x为何值时,f(x)最大)
     68 
     69     system("pause");
     70     return 0;
     71 
     72 }//end of main                                              
     73 
     74 
     75 //创建初始群体                               
     76 void randCreatePop(Chromosome *pop)
     77 {
     78     UINT i,j;
     79     UINT randValue;
     80     UINT value;
     81 
     82     srand((unsigned)time(NULL));   //如果所有的函数都要使用到rand函数,只需要在先运行的函数使用一次srand即可
     83     for(i=0; i<POP_NUM; i++)       // 从种群中的第1个染色体到第POP_NUM个染色体
     84     {
     85         for(j=0; j<GENE_NUM; j++)  // 从染色体的第1个基因位到第GENE_NUM个基因位
     86         {
     87             randValue         = rand()%2;      // 随机产生0或者1                       
     88             pop[i].geneBit[j] = randValue+'0'; // 将随机数(0,1)赋给基因位
     89         }   
     90 
     91         value           = binToDec(pop[i]);    // 计算染色体基因对应的值
     92         pop[i].fitValue = calcFitValue(value); // 计算染色体的适应度值
     93     }                                                                        
     94 
     95 #if (TEST==1) && (TEST_FLAG==1) //测试
     96     printf("
    随机分配的种群如下:
    ");
     97     test(pop);
     98 #endif
     99 
    100 }//end of createPop
    101 
    102 //选择(Selection):根据适应度选择优良个体(最优解) 
    103 void selection(Chromosome *pop) 
    104 {
    105     UINT   i,j;
    106     UINT  sumFitValue;        //总适应值
    107     UINT  avrFitValue;        //平均适应值
    108     float choicePro[POP_NUM]; //选择机会
    109     Chromosome tempPop;       //临时种群变量
    110 
    111 #if (TEST==1) && (TEST_FLAG==2) //测试
    112     printf("
    没有选择前的种群如下:
    ");
    113     test(pop);
    114 #endif
    115 
    116     // 根据个体适应度来排序(冒泡法) 降序
    117     for(i=POP_NUM; i>0; i--)                           
    118     {
    119         for(j=0; j<(i-1); j++)
    120         {
    121             if(pop[j+1].fitValue > pop[j].fitValue)
    122             {
    123                 tempPop  = pop[j+1];
    124                 pop[j+1] = pop[j];
    125                 pop[j]   = tempPop;
    126             }   
    127         }                
    128     }
    129     
    130     //计算出总适应值
    131     sumFitValue = 0;
    132     for(i=0; i<POP_NUM; i++)
    133     {
    134         sumFitValue += pop[i].fitValue;
    135     }
    136 
    137     //计算出平均适应值(四舍五入,保留到小数点后1位)
    138     avrFitValue = (UINT)(((float)sumFitValue/POP_NUM)+0.5);
    139 
    140     //计算出每个群体选择机会
    141     for(i=0; i<POP_NUM; i++)                             //群体的概率   = 群体适应值/总适应值
    142     {                                                     //平均概率        = 平均适应值/总适应值
    143         //群体选择机会 = (群体的概率/平均概率)
    144         choicePro[i] = ((float)pop[i].fitValue/sumFitValue)/((float)avrFitValue/sumFitValue); 
    145         choicePro[i] = (float)((int)(choicePro[i]*100+0.5)/100.0);//保留到小数点后2位,四舍五入
    146         printf("%f
    ", choicePro[i]);
    147     }                                                     
    148 
    149     //根据选择概率来繁殖(copy)优良个体、淘汰较差个体
    150     //如果choicePro[i]==0淘汰复制一次最优的群体
    151     for(i=0; i<POP_NUM; i++)
    152     {
    153         if(((int)(choicePro[i]+0.55)) == 0)
    154             pop[POP_NUM-1] = pop[0];
    155     }
    156 
    157 #if (TEST==1) && (TEST_FLAG==2) //测试
    158     printf("
    经过选择的种群如下:
    ");
    159     test(pop);
    160 #endif
    161 
    162 }//end of selection
    163 
    164 //交叉(Crossover):染色体的片断(基因)进行交换
    165 void crossover(Chromosome *pop)  
    166 { 
    167     char  tmpStr[GENE_NUM]="";
    168     UINT  i;
    169     UINT  randPos;
    170     UINT  randValue;
    171 
    172     //    srand( (unsigned)time( NULL ) );
    173     randValue=rand()%100;   // 随机产生0到49之间的数;
    174     if(randValue >= (int)(CROSS_RATE*100)) // randValue<50的概率只有50%,即变异率为0.5
    175     {
    176 #if (TEST==1) && (TEST_FLAG==3) //测试
    177         printf("
    种群没有进行交叉.
    ");
    178 #endif
    179 
    180         return ;
    181     }
    182 
    183 #if (TEST==1) && (TEST_FLAG==3) //测试
    184     printf("
    交叉前,种群如下:
    ");
    185     test(pop);
    186     printf("
    交叉的位置依次为:");
    187 #endif
    188 
    189     //种群中个体染色体两两交叉
    190     for(i=0; i<POP_NUM; i+=2)
    191     {
    192         //crossover child i and child i+1
    193         randPos = (rand()%(GENE_NUM-1)+1);   // 随机产生交叉点,交叉点控制在1到(GENE_NUM-1)之间
    194         strncpy(tmpStr, pop[i].geneBit+randPos, GENE_NUM-randPos);
    195         strncpy(pop[i].geneBit+randPos, pop[i+1].geneBit+randPos, GENE_NUM-randPos);
    196         strncpy(pop[i+1].geneBit+randPos, tmpStr, GENE_NUM-randPos);
    197 
    198 #if (TEST==1) && (TEST_FLAG==3) //测试
    199         printf(" %d", randPos);
    200 #endif
    201     }
    202 
    203     // 为新个体计算适应度值
    204     for(i=0; i<POP_NUM; i++)
    205     {
    206         pop[i].fitValue = calcFitValue( binToDec(pop[i]) );     
    207     }
    208 
    209 #if (TEST==1) && (TEST_FLAG==3) //测试
    210     printf("
    交叉后,种群如下:
    ");
    211     test(pop);
    212 #endif
    213 
    214 }//end of crossover
    215 
    216 //变异(Mutation) :随机改变染色体片断(基因)的值
    217 void mutation(Chromosome *pop)   
    218 {
    219     UINT randRow, randCol;  
    220     UINT randValue;
    221 
    222     //    srand( (unsigned)time( NULL ) );    
    223     randValue=rand()%100;   // 随机产生0到99之间的数;
    224     if(randValue >= (int)(MUT_RATE*100)) // randValue<2的概率只有2%,即变异率为0.02
    225     {
    226 #if (TEST==1) && (TEST_FLAG==4) //测试
    227         printf("
    种群中没有基因变异.
    ");
    228 #endif
    229 
    230         return ;
    231     }
    232 
    233     randCol = rand()%GENE_NUM;    // 随机产生要变异的基因位号 
    234     randRow = rand()%POP_NUM;     // 随机产生要变异的染色体号
    235 
    236 #if (TEST==1) && (TEST_FLAG==4)   //测试
    237     printf("
    变异前,种群如下:
    ");
    238     test(pop);
    239     printf("
    变异的位置:染色体号=%d 基因位号=%d
    ", randRow+1, randCol);
    240 #endif
    241 
    242     pop[randRow].geneBit[randCol] = (pop[randRow].geneBit[randCol]=='0') ? '1':'0'; //1变为0, 0变为1
    243     pop[randRow].fitValue = calcFitValue( binToDec(pop[randRow]) ); // 计算变异后的适应度值 
    244 
    245 #if (TEST==1) && (TEST_FLAG==4) //测试
    246     printf("
    变异后,种群如下:
    ");
    247     test(pop);
    248 #endif
    249 
    250 }//end of mutation
    251 
    252 //更新种群
    253 void updatePop(Chromosome *newPop, Chromosome *oldPop)
    254 {
    255     UINT i;
    256 
    257     for(i=0; i<POP_NUM; i++)  
    258     {
    259         oldPop[i]=newPop[i];    
    260     }
    261 
    262 }//end of updatePop
    263 
    264 //打印结果(当x为何值时,f(x)最大)
    265 void printResult(Chromosome *pop)    
    266 {         
    267     UINT i;
    268     UINT x = 0;
    269     UINT optValue = 0;  // 函数的最优值
    270 
    271     for(i=0; i<POP_NUM; i++)
    272     {
    273         if(pop[i].fitValue > optValue)
    274         {
    275             optValue = pop[i].fitValue;
    276             x = binToDec(pop[i]);
    277         }
    278 
    279     }
    280 
    281     printf("
    当x=%d时,函数得到最大值为:%d
    
    ", x, optValue);
    282 
    283 }//end of printResult
    284 
    285 
    286 //计算染色体的适应度值
    287 UINT calcFitValue(UINT x)
    288 {
    289     return FUN_EXP(x);  // 
    290 
    291 }//end of calcFitValue
    292 
    293 //将类似二进制的基因位转化为十进制    
    294 UINT binToDec(Chromosome pop)            
    295 {
    296     UINT i;
    297     UINT radix  = 1;
    298     UINT result = 0;
    299 
    300     for(i=0; i<GENE_NUM; i++)
    301     {    //printf("%d", pop.geneBit[i]);
    302         result += (pop.geneBit[i]-'0')*radix;
    303         radix  *= 2;
    304     }
    305 
    306     return result;
    307 
    308 }//end of binToDec
    309 
    310 void test(Chromosome *pop)
    311 {
    312     int i;
    313     int j;
    314 
    315     for(i=0; i<POP_NUM; i++)
    316     {
    317         printf("%d: ", i+1);
    318         for(j=0; j<GENE_NUM; j++)
    319             printf("%c", pop[i].geneBit[j]);
    320 
    321         printf("   %4d", binToDec(pop[i]));
    322         printf("   fixValue=%d
    ", calcFitValue(binToDec(pop[i])));
    323     }
    324 }

     

    转载:http://blog.csdn.net/dl0914791011/article/details/8161253

     

  • 相关阅读:
    关于C++类中的静态数据成员
    关于C++中char,sizeof,strlen,string
    C++学习笔记(7)
    C++学习笔记(6)
    C++学习笔记(指针)
    C++学习笔记(4)
    UVA 10780
    UVA 531
    HDU, 3579 Hello Kiki
    UVA, 10413 Crazy Savages
  • 原文地址:https://www.cnblogs.com/hdu-2010/p/4322848.html
Copyright © 2011-2022 走看看