- 1
- 2
- 3
- 4
- 5
- 6
- 7
class tree
{
tree *child;
tree(){
child=new tree[1]; //никогда так не делать!!
}
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+172
class tree
{
tree *child;
tree(){
child=new tree[1]; //никогда так не делать!!
}
};
+152
#include "stdafx.h"
#include "angel.h"
#include "angelDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CangelApp, CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CangelApp::CangelApp()
{}
CangelApp theApp;
BOOL CangelApp::InitInstance()
{
InitCommonControls();
CWinApp::InitInstance();
AfxEnableControlContainer();
CangelDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
Подумаю об этом завтра, ну или когда там?!
+164
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
Ну чтобы уж точно обработать все runtime-отбросы.
+174
BOOL CAnalysisWindow::OnControlStatus(void* msg)
{
TypeControlStatus* ControlStatus = (TypeControlStatus*)msg;
if (ControlStatus->Total > 12)
{
m_ProgressBar.ShowWindow(0);
m_ProgressBar2.ShowWindow(0);
...
m_ProgressBar12.ShowWindow(0);
}
else
{
m_ProgressBar.ShowWindow(ControlStatus->Total > 0);
m_ProgressBar2.ShowWindow(ControlStatus->Total > 1);
...
m_ProgressBar12.ShowWindow(ControlStatus->Total > 11);
}
if (ControlStatus->Current == 1)
{
m_ProgressBar.SetRange(0, ControlStatus->Total);
}
m_ProgressBar.SetPos(ControlStatus->Current);
if (ControlStatus->Current == 2)
{
m_ProgressBar2.SetRange(1, ControlStatus->Total);
}
m_ProgressBar2.SetPos(ControlStatus->Current);
...
if (ControlStatus->Current == 12)
{
m_ProgressBar12.SetRange(11, ControlStatus->Total);
}
m_ProgressBar12.SetPos(ControlStatus->Current);
return TRUE;
}
Как сделать прогресс бар c 12-ю делениями? Ответ прост: воспользоваться 12-ю прогресс барами, по одному на каждое деление.
Самое интересное, как отрисовывается общий прогресс на 12 маленьких прогресс барах.
+145
#include <stdio.h>
int main(int argc,char argv)
{
int start=90;
int end=2;
int divd=10;
for(int i=start;i>=end;i--)
{
if(i>=10){
for(int nm=10;nm>=1;nm--)
{
int res=i/nm;
int ost=i%nm;
if(ost==0 && res<=10)printf("%d=%d*%d\n",i,res,nm);
};
} else {
for(int nm=i;nm>=1;nm--)
{
int res=i/nm;
int ost=i%nm;
if(ost==0)printf("%d=%d*%d\n",i,res,nm);
};
};
};
return 0;
};
Таблица умножения
+181
void MultipleSquareMatrix(Matrix*rres, Matrix*mul1, Matrix* mul2)
{
int N = mul1->height();
Matrix rmul1(N,N);
Matrix rmul2(N,N);
#define SM (CLS / sizeof (double))
for (i = 0; i < N; i += SM)
for (j = 0; j < N; j += SM)
for (k = 0; k < N; k += SM)
for (i2 = 0, rres = &res[i][j],
rmul1 = &mul1[i][k]; i2 < SM;
++i2, rres += N, rmul1 += N)
for (k2 = 0, rmul2 = &mul2[k][j];
k2 < SM; ++k2, rmul2 += N)
for (j2 = 0; j2 < SM; ++j2)
rres[j2] += rmul1[k2] * rmul2[j2];
}
Перемножение квадратных матриц.....
+164
// Licensed to Green Energy Corp (www.greenenergycorp.com) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. Green Enery Corp licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
#include "Objects.h"
#define MACRO_STATIC_INSTANCE(group, var) Group##group##Var##var Group##group##Var##var::mInstance;
namespace apl { namespace dnp {
MACRO_STATIC_INSTANCE(1,0)
MACRO_STATIC_INSTANCE(1,1)
MACRO_STATIC_INSTANCE(1,2)
MACRO_STATIC_INSTANCE(2,0)
MACRO_STATIC_INSTANCE(2,1)
MACRO_STATIC_INSTANCE(2,2)
MACRO_STATIC_INSTANCE(2,3)
<... 100500 строк ...>
MACRO_STATIC_INSTANCE(60,1)
MACRO_STATIC_INSTANCE(60,2)
MACRO_STATIC_INSTANCE(60,3)
MACRO_STATIC_INSTANCE(60,4)
MACRO_STATIC_INSTANCE(80,1)
MACRO_STATIC_INSTANCE(110,0)
MACRO_STATIC_INSTANCE(111,0)
MACRO_STATIC_INSTANCE(112,0)
MACRO_STATIC_INSTANCE(113,0)
//////////////////////////////////////////////
// Binary Input Types
//////////////////////////////////////////////
void Group1Var2::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQ(p, Group1Var2::Inst(), v); }
void Group2Var1::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQ(p, Group2Var1::Inst(), v); }
void Group2Var2::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQT(p, Group2Var2::Inst(), v); }
void Group2Var3::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQT(p, Group2Var3::Inst(), v); }
Binary Group1Var2::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group1Var2::Inst()); }
Binary Group2Var1::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group2Var1::Inst()); }
Binary Group2Var2::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group2Var2::Inst()); }
Binary Group2Var3::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQVT(p, Group2Var3::Inst()); }
"We provide world-class engineering services to companies leading the smart energy revolution."
посредством копипасты. малаца.
+168
TOutputConsoleWindow::TOutputConsoleWindow(void)
{
//...
_mainWindow = new TConsoleOutputWindow(Rect);
+168
class TalentsWindow : public PopupWindow {
render::Sprite* m_background_sprite, *m_header_sprite, *m_fucking_sprite;
...
...
};
...
TalentsWindow::TalentsWindow()
{
...
m_fucking_sprite = m_sprites.addSprite(render::SpriteRect(NOINITIALIZE)
.setTop(591.0f)
.setLeft(500.0f)
.setWidth(411.0f)
.setHeight(140.0f),
m_tex,
0.85f
);
m_fucking_sprite->setPosition(math::float2(818.0f, 50.0f));
m_fucking_sprite->idiot = true;
...
}
Самодокументирующий код.
+145
#ifndef UTF8_ONLY
I HATE YOU!!!!
#endif