1. C++ / Говнокод #2971

    +60.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    bool CMLayer::operator==(CMLayer ^a, CMLayer ^b)
    {
    	CLayer *pA;
    	CLayer *pB;
    	bool bA = false;
    	bool bB = false;
    
    	// Проверка в катче
    	try
    	{
    		pA = a->m_pelMain;
    	}
    	catch (System::NullReferenceException ^)
    	{
    		pA = NULL;
    		bA = true;
    	}
    
    	// Проверка в катче
    	try
    	{
    		pB = b->m_pelMain;
    	}
    	catch (System::NullReferenceException ^)
    	{
    		pB = NULL;
    		bB = true;
    	}
    
    	if ((bA == true) && (bB == true))
    		return true;
    	else if ((bA == true) || (bB == true))
    		return false;
    
    	return pA == pB;
    }

    Код на Management C++, тот кто его писал был явно в ажуре))))
    Проверяются указатели на внутрении данные, а штоб System::NullReferenceException не выскакивал при сравнее на null все сделанно в катче

    Snake2101, 09 Апреля 2010

    Комментарии (17)
  2. C++ / Говнокод #2970

    +144.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    bool PathProcessor::Process(PPProcess *pProcess)
    {
    	std::vector<int> viRoute; int nRouteCount; bool bRetVal = false;
    	for (int i = 0; i < m_viExcludeStop.size(); i++){
    		if (m_viExcludeStop[i] == pProcess->nStartStopId) return false;
    	}
    	int bbb = 0;
    	if (pProcess->nRouteId < 0){
    		viRoute = GetRoutesID(pProcess->nStartStopId);
    		nRouteCount = viRoute.size();
    		if (nRouteCount <= 0) return false;
    	}
    	else{
    		viRoute = GetRoutesID(pProcess->nStartStopId, pProcess->nRouteId);
    		nRouteCount = viRoute.size();
    		if (nRouteCount <= 0) return false;
    		nRouteCount = 1;
    	}
    	for (int i = 0; i < nRouteCount; i++){
    		RouteDataInfo rdCur = GetRoute(viRoute[i]);
    		pProcess->nRoutePartId = rdCur.nId;
    		PPResult *pRes;
    		bool bCurRetVal = false;
    		if (pProcess->bIsFirstStop == true){
    			pRes = new PPResult();
    			pRes->bFinished = false;
    			pRes->nFirstStopId = pProcess->nFirstId;
    			pRes->nLastStopId = -1;
    			pRes->nRouteId = rdCur.nRouteId;
    			m_viResult.push_back(pRes);
    		}
    		else pRes = pProcess->pLastResult;
    		if (pRes != NULL){
    			PartInfo piTemp(rdCur.nId, rdCur.nLastStopId);
    			pRes->viPartsId.push_back(piTemp);
    		}
    		if (IsEndStop(rdCur.nLastStopId) == true){
    			if (pRes != NULL){
    				pRes->bFinished = true;
    				pRes->nLastStopId = rdCur.nLastStopId;
    			}
    			bRetVal = true;	bCurRetVal = true;
    		}
    		if ((pProcess->IsStopExist(rdCur.nLastStopId) == false) && (bCurRetVal == false)){
    			if ((pProcess->nCurStep < m_nMaxStep) && (pProcess->nRouteId >= 0)){
    				PPProcess ppProc;
    				ppProc.nCurStep = pProcess->nCurStep;
    				ppProc.nRouteId = pProcess->nRouteId;
    				ppProc.nStartStopId = rdCur.nLastStopId;
    				ppProc.pPrevProc = pProcess;
    				ppProc.bIsFirstStop = false;
    				ppProc.nFirstId = pProcess->nFirstId;
    				if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
    				else ppProc.pLastResult = pProcess->pLastResult;
    				if (Process(&ppProc) == true) bRetVal = true;
    			}
    			else if (pProcess->nCurStep < m_nMaxStep){
    				PPProcess ppProc;
    				ppProc.nCurStep = pProcess->nCurStep;
    				ppProc.nRouteId = rdCur.nRouteId;
    				ppProc.nStartStopId = rdCur.nLastStopId;
    				ppProc.pPrevProc = pProcess;
    				ppProc.bIsFirstStop = false;
    				ppProc.nFirstId = pProcess->nFirstId;
    				if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
    				else ppProc.pLastResult = pProcess->pLastResult;
    				if (Process(&ppProc) == true) bRetVal = true;
    			}
    			if (pProcess->nCurStep+1 < m_nMaxStep){
    				PPProcess ppProc2;
    				ppProc2.nCurStep = pProcess->nCurStep+1;
    				ppProc2.nRouteId = -1;
    				ppProc2.nStartStopId = rdCur.nLastStopId;
    				ppProc2.pPrevProc = pProcess;
    				ppProc2.bIsFirstStop = true;
    				ppProc2.nFirstId = rdCur.nLastStopId;
    				ppProc2.pLastResult = NULL;
    				if (Process(&ppProc2) == true){
    					PPResult *pRes2;
    					pRes2 = new PPResult();
    					pRes2->bFinished = true;
    					pRes2->nFirstStopId = pRes->nFirstStopId;
    					pRes2->nLastStopId = rdCur.nLastStopId;
    					pRes2->nRouteId = pRes->nRouteId;
    					PPProcess *pProc = pProcess;
    					while (pProc != NULL){
    						PartInfo piTemp(pProc->nRoutePartId, pProc->nStartStopId);
    						pRes2->viPartsId.push_back(piTemp);
    						pProc = pProc->pPrevProc;
    					}
    					m_viResult.push_back(pRes2); bRetVal = true;
    				}
    			}
    		}
    	}
    	if ((bRetVal == false) && (pProcess->nRouteId < 0))
    		m_viExcludeStop.push_back(pProcess->nStartStopId);
    	return bRetVal;
    }

    Когда-то давно писал алгоритм поиска маршрутов, теперь удевляюсь как это все работает да еще и не виснет

    Snake2101, 09 Апреля 2010

    Комментарии (3)
  3. C++ / Говнокод #2969

    +144.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    #include "stdafx.h"
    #include "windows.h"
    
    #define число int
    #define если if
    #define иначе else
    #define начало {
    #define конец }
    #define НОЛЬ NULL
    #define Сообщение MessageBoxA
    #define КНОПКА_ОК MB_OK
    #define возврат
    #define присвоить =
    #define равняется ==
    #define больше >
    #define ТочкаВхода _tmain
    #define Строка _TCHAR
    #define УКАЗАТЕЛЬ *
    #define КонецСтроки ;
    #define СлучайноеЧисло rand
    #define Посев srand
    #define ВзятьКоличествоТиков GetTickCount
    
    /****************************************************************************************************/
    /*																									*/
    /****************************************************************************************************/
    число ТочкаВхода(число КоличествоПараметров, Строка УКАЗАТЕЛЬ Параметры[])
    {
    	Посев(ВзятьКоличествоТиков());
    	число новое присвоить СлучайноеЧисло() КонецСтроки
    	если (новое больше 10000) начало
    		Сообщение(НОЛЬ, "Больше 10000", НОЛЬ, КНОПКА_ОК) КонецСтроки
    	конец иначе начало
    		Сообщение(НОЛЬ, "Меньше 10000", НОЛЬ, КНОПКА_ОК) КонецСтроки
    	конец
    
    	возврат 0 КонецСтроки
    }

    Ооо могучий C++

    Snake2101, 09 Апреля 2010

    Комментарии (25)
  4. C++ / Говнокод #2966

    +144.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    A* arr = new A[size];
    std::vector<A*> vec(size);
    for(size_t i=0; i<size; ++i)
    	vec.push_back(&a[i])
    // Do something with vec
    delete[] arr;

    kokorins, 08 Апреля 2010

    Комментарии (9)
  5. C++ / Говнокод #2915

    +144.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    /**
     * Helper classes for computing window query on rectangles
     */
    
    class VerticalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      VerticalSegmentIntersect ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() { 
        QRect const* area = inpGlyph->GetGlyphArea();
        ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
        
        if (y < x - m_Rhs ) return 0;
        if (y < m_Lhs - x ) return 0;
        
        return 1;
      }
    };
    
    class HorisontalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      HorisontalSegmentIntersect ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() { 
        QRect const* area = inpGlyph->GetGlyphArea();
        ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
        
        if (y < x - m_Rhs ) return 0;
        if (y < m_Lhs - x ) return 0;
        return 1;
      }
    };
    
    /**
     * Helper classes for computing containment query on rectangles
     */ 
    
    class VerticalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      VerticalSegmentContains ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
        QRect const* area = inpGlyph->GetGlyphArea();    
        ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
        
        if ( y > x - m_Lhs ) return 0;
        if ( y > m_Rhs - x ) return 0;
        return 1;
      }
    };
    
    class HorisontalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      HorisontalSegmentContains ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
        QRect const* area = inpGlyph->GetGlyphArea();    
        ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
        
        if ( y > x - m_Lhs ) return 0;
        if ( y > m_Rhs - x ) return 0;
        return 1;
      }
    };
    
    // compute the window query on m_GlyphData rectangles
      QVector<PRGlyph> :: iterator windowq = m_Selection.isValid() ?
                                            std::partition ( m_GlyphData.begin(),
                                                             std::partition ( m_GlyphData.begin(), m_GlyphData.end(), VerticalSegmentIntersect ( m_Selection.top(), m_Selection.bottom() ) ),
                                                             HorisontalSegmentIntersect ( m_Selection.left(), m_Selection.right() )
                                                           ) : m_GlyphData.begin();
      // compute the containment query on window query rectangles (the containment query resuls is always subset of window query )
      QVector<PRGlyph> :: iterator containq = std::partition ( m_GlyphData.begin(),
                                                               std::partition ( m_GlyphData.begin(), windowq, VerticalSegmentContains ( m_Selection.top(), m_Selection.bottom() ) ),
                                                               HorisontalSegmentContains ( m_Selection.left(), m_Selection.right() )
                                                             );

    Способ быстренько находить прямоугольники, пересекающиеся с входным и содержимые им же. Применимо для прямоугольных параллелепипедов любой размерности.

    ngry, 01 Апреля 2010

    Комментарии (27)
  6. C++ / Говнокод #2914

    +912.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int n;
        cin>>n;
        if(n==1) cout<<"A";
        if(n==2) cout<<"B";
        if(n==3) cout<<"AB";
        if(n==4) cout<<"BAB";
        if(n==5) cout<<"ABBAB";
        if(n==6) cout<<"BABABBAB";
        if(n==7) cout<<"ABBABBABABBAB";
        if(n==8) cout<<"BABABBABABBABBABABBAB";
        if(n==9) cout<<"ABBABBABABBABBABABBABABBABBABABBAB";
        if(n==10) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==11) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==12) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==13) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==14) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        if(n==15) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
        return 0;
    }

    строки Фибаначи. (=

    winprogrammer, 01 Апреля 2010

    Комментарии (32)
  7. C++ / Говнокод #2899

    +54.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    #include <iostream>
    
    class TerVer {
    public:
      short d1, d2, d3, d4;
      short totalCounter, goodCounter;
      bool DoneInc;
      TerVer(): d1(1), d2(0), d3(0), d4(0), totalCounter(1), goodCounter(0), DoneInc(false) {}
      bool IsGood() {
        return (
          (d1==d2 && d1!=d3 && d1!=d4 && d3!=d4) ||
          (d1==d3 && d1!=d2 && d1!=d4 && d2!=d4) ||
          (d1==d4 && d1!=d2 && d1!=d3 && d2!=d3) ||
    
          (d2==d3 && d2!=d1 && d2!=d4 && d1!=d4) ||
          (d2==d4 && d2!=d1 && d2!=d3 && d1!=d3) ||
    
          (d3==d4 && d3!=d1 && d3!=d2 && d1!=d2)
          ) ? true : false;
      }
      void Inc() {
        d4++; 
        if(d4>9) { d4=0; d3++; if(d3>9) {d3=0; d2++; if(d2>9) { d2=0; d1++; if(d1>9) DoneInc = true; } } }
        if (!DoneInc) { totalCounter++; if (IsGood()) goodCounter++; }
      }
    };
    
    int main() {
      TerVer z;
      while(!z.DoneInc) {
        z.Inc();
      }
      cout << z.goodCounter << " / " << z.totalCounter << " = " << (double)z.goodCounter/z.totalCounter << endl;
    
      return 0;
    }

    Найти вероятность того, что в случайном четырехзначном числе ровно две цифры совпадают.
    Вот что бывает, когда лень думать.

    elmigranto, 30 Марта 2010

    Комментарии (24)
  8. C++ / Говнокод #2892

    +940.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    bool checkForExe(std::string ext)
    {
        return ext==".exe" ? true : 
                  ext==".Exe" ? true :
                  ext==".eXe" ? true :
                  ext==".EXe" ? true :
                  ext==".exE" ? true :
                  ext==".ExE" ? true :
                  ext==".eXE" ? true :
                  ext==".EXE" ? true : false;
    }

    Нашел в одной моей очень древней программе-шутке. Регистронезависимая проверка на расширение .exe.

    frp, 29 Марта 2010

    Комментарии (48)
  9. C++ / Говнокод #2888

    +144.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #define THIS_FILE __FILE__
    #define Default 0xFFFFFFFF
    
    void* __cdecl operator new(size_t nSize, LPCSTR lpszFileName, int nLine=Default)
    {
    void * v = ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
    return v;
    }
    
    void __cdecl operator delete(void * _P, char*){
    ::delete (_P);
    }

    Какие страсти...

    Говногость, 29 Марта 2010

    Комментарии (10)
  10. C++ / Говнокод #2857

    +59.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    void addItem(QStringList &lst, QTreeWidget *ptwg)
    {
    	bool a0 = false;
    	for (int i = 0; i < ptwg->topLevelItemCount(); ++i) {
    		if (lst.at(0) == ptwg->topLevelItem(i)->text(0)) {
    			a0 = true;
    			bool a1 = false;
    			QTreeWidgetItem *itm0 = ptwg->topLevelItem(i);
    			for (int j = 0; j < itm0->childCount(); ++j) {
    				if (lst.at(1) == itm0->child(j)->text(1)) {
    					a1 = true;
    					bool a2 = false;
    					QTreeWidgetItem *itm1 = itm0->child(j);
    					for (int k = 0; k < itm1->childCount(); ++k) {
    						if (lst.at(2) == itm1->child(k)->text(2)) {
    							a2 = true;
    							bool a3 = false;
    							QTreeWidgetItem *itm2 = itm1->child(k);
    							for (int l = 0; l < itm2->childCount(); ++l) {
    								if (lst.at(3) == itm2->child(l)->text(3)) {
    									a3 = true;
    									QTreeWidgetItem *itm3 = itm2->child(l);
    									QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
    									break;
    								}
    							}
    							if (!a3) {
    								QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
    								QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
    							}
    							break;
    						}
    					}
    					if (!a2) {
    						QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm1, QStringList() << "" << "" << lst.at(2));
    						QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
    						QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
    					}
    					break;
    				}
    			}
    			if (!a1) {
    				QTreeWidgetItem *itm1 = new QTreeWidgetItem(itm0, QStringList() << "" << lst.at(1));
    				QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm1, QStringList() << "" << "" << lst.at(2));
    				QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
    				QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
    			}
    			break;
    		}
    	}
    	if (!a0) {
    		QTreeWidgetItem *itm0 = new QTreeWidgetItem(ptwg, QStringList() << lst.at(0));
    		QTreeWidgetItem *itm1 = new QTreeWidgetItem(itm0, QStringList() << "" << lst.at(1));
    		QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm1, QStringList() << "" << "" << lst.at(2));
    		QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
    		QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
    	}
    }

    Функция = ) Добавляет в контрол иерархического дерева (5 уровней) элемент, не перерисовывая при этом само дерево, не закрывая никаких открытых веток.

    JC_NVKZ, 24 Марта 2010

    Комментарии (5)