All pastes #543992 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-06-06 07:43 UTC
rendered paste body
#include <iostream>#include <iomanip>int A[100];int LENGTH, SUB_LEN;int index;void PRINT(){        index++;        cout << " The index " << index << "-->";        for ( int x = 0; x < LENGTH; x++ )  cout << A[x];        cout << endl;  }bool CHECK(){                int running_variable;                int TEMP = SUB_LEN;                int X = 0;                                                do                 {                        running_variable = X;                          /*--------------------------START---------------------------------------*/                        do                         {                                int repeat_times = 0;                                int Y = 0;                                                                 for ( int i = running_variable; i < TEMP; i++)                                {                                                                        if ( A[i] == A[Y+TEMP] )                                        {                                                repeat_times++;                                                Y++;                                        }                                        else break; /*Thoat khoi for neu có dã có bat kì 1 phan tu thuoc day truoc                                                       khac day sau thì ko càn xet tiep nua */                                  }                                                                                                            /* Thoát khoi ham ngay lap túc, dãy da ko thoa dk */                                          if ( repeat_times == SUB_LEN )                                          {                                                  return false;                                           }                                                                                                                                                                                          running_variable = running_variable + SUB_LEN;                                          TEMP = TEMP + SUB_LEN;                                        } while ( running_variable < LENGTH - SUB_LEN );                                             /*--------------------------END-----------------------------------------*/                                                                              X++; /* Lùi vào trong xét 1 dãy con moi */                        TEMP = SUB_LEN + X; /* Do dài chuoi con thay doi theo X */                        } while ( X < LENGTH/SUB_LEN );               }                void BACKTRACK ( int i ){        for ( int j = 0; j <= 1; j++ )        {                A[i] = j;                if ( i == LENGTH - 1 )                {                                if ( CHECK() != false )                                PRINT();                }                else                 {                                BACKTRACK ( i + 1 );                }        }}void main(){        index = 0;        cout << "Enter a number : "; cin >> LENGTH;        cout << "Enter a length : "; cin >> SUB_LEN;        for ( int x = 0; x < LENGTH; x++ ) A[x] = 0;                BACKTRACK (0);                cin >> index; /*PAUSE SYSTEM*/}