- 1
- 2
- 3
<?
echo $i++ + ++$i;
?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+144.8
<?
echo $i++ + ++$i;
?>
+144.8
#ifndef __gen_spi_h
#define __gen_spi_h
#ifndef SPI_PORT_TYPE_OVERRIDE
#define SPI_PORT_TYPE unsigned int
#endif
#ifndef SPI_BYTE_TYPE_OVERRIDE
#define SPI_BYTE_TYPE unsigned char
#endif
// SPI SS SIGNAL --- OUT
#define DECL_SS(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_SS_POUT = &(P##OUT); \
volatile SPI_PORT_TYPE *const _##N##_SS_PDIR = &(P##DIR); \
const SPI_PORT_TYPE _##N##_SS_BIT = B
// SPI SCK SIGNAL --- OUT
#define DECL_SCK(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_SCK_POUT = &P##OUT; \
volatile SPI_PORT_TYPE *const _##N##_SCK_PDIR = &(P##DIR); \
const SPI_PORT_TYPE _##N##_SCK_BIT = B
// SPI MOSI SIGNAL --- OUT
#define DECL_MOSI(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_MOSI_POUT = &P##OUT; \
volatile SPI_PORT_TYPE *const _##N##_MOSI_PDIR = &P##DIR; \
const SPI_PORT_TYPE _##N##_MOSI_BIT = B
// SPI MISO SIGNAL --- IN
#define DECL_MISO(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_MISO_PIN = &P##IN; \
volatile SPI_PORT_TYPE *const _##N##_MISO_PDIR = &P##DIR; \
const SPI_PORT_TYPE _##N##_MISO_BIT = B
#define SETSS(N) *(_##N##_SS_POUT) |= _##N##_SS_BIT
#define CLRSS(N) *(_##N##_SS_POUT) &= ~(_##N##_SS_BIT)
#define SETMOSI(N) *(_##N##_MOSI_POUT) |= _##N##_MOSI_BIT
#define CLRMOSI(N) *(_##N##_MOSI_POUT) &= ~(_##N##_MOSI_BIT)
#define SETCLK(N) *(_##N##_SCK_POUT) |= _##N##_SCK_BIT
#define CLRCLK(N) *(_##N##_SCK_POUT) &= ~(_##N##_SCK_BIT)
#define READMISO(N) (((*(_##N##_MISO_PIN)) & _##N##_MISO_BIT) != 0)
#define SPI_SETUP(N) \
SETSS(N); \
*(_##N##_SCK_PDIR) |= _##N##_SCK_BIT; \
*(_##N##_MOSI_PDIR) |= _##N##_MOSI_BIT; \
*(_##N##_SS_PDIR) |= _##N##_SS_BIT; \
*(_##N##_MISO_PDIR) &= ~(_##N##_MISO_BIT); \
CLRSS(N); \
SETSS(N)
#define DECL_SPI_TRANS_BYTE(N) \
SPI_BYTE_TYPE _##N##_spi_trans_byte(SPI_BYTE_TYPE val) { \
register SPI_BYTE_TYPE bitnum; \
for (bitnum = 0; bitnum < 8; bitnum++) { \
if (val & 0x80) SETMOSI(N); \
else CLRMOSI(N); \
val <<= 1; \
SETCLK(N); \
val |= READMISO(N); \
CLRCLK(N); \
} \
return val; \
} \
#define SPI_BEGIN(N) SETSS(N);CLRSS(N)
#define SPI_END(N) SETSS(N)
#define SPI_TRANS_BYTE(N, B) _##N##_spi_trans_byte((B))
#endif
+144.8
<li><script type="text/javascript" src="http://reformal.ru/tab.js?title=%C3%EE%E2%ED%EE%EA%EE%E4.%F0%F3%3A+%EF%EE+%EA%EE%EB%E5%ED%EE+%E2+%EA%EE%E4%E5&domain=govnokod&color=adadad&align=left&charset=utf-8&ltitle=%CE%F2%E7%FB%E2%FB&lfont=Verdana,%20Geneva,%20sans-serif&lsize=11px&waction=0&regime=1"></script></li>
А теперь отгадайте с какого это сайта
+144.8
<?php
if(!@isset($_POST[submit]))
{
...
?>
+144.8
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;
}
Когда-то давно писал алгоритм поиска маршрутов, теперь удевляюсь как это все работает да еще и не виснет
+144.8
#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++
+144.8
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;
+144.8
<table width="100%">
<tr>
<td><input name="res" title="add new resource"/><td>
</tr>
</table>
а ведь это должен был быть <div>..</div> =)
+144.8
/**
* 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() )
);
Способ быстренько находить прямоугольники, пересекающиеся с входным и содержимые им же. Применимо для прямоугольных параллелепипедов любой размерности.
+144.8
#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);
}
Какие страсти...