- 1
#define HESHELME_BESHELME(x, y) (((x)>0)<<2 | ((y)>0)<<1 | ((x) > ((x)*(y) > 0 ? (y) : -(y))))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+102
#define HESHELME_BESHELME(x, y) (((x)>0)<<2 | ((y)>0)<<1 | ((x) > ((x)*(y) > 0 ? (y) : -(y))))
двумерное "квантование" точки
+157
ГК - Городская Канализация.
+75
int i128 = 0, i256 =0, i384=0, i512=0, i640=0, i786=0, i896=0, i1024=0, i1152=0, i1280=0, i1408=0, i1536=0;
for (int index: data) {
if (index>max) max = index;
if (min>index) min = index;
if (0<=index & index<128) i128++;
else if (128<=index & index<256) i256++;
else if (256<=index & index<384) i384++;
else if (384<=index & index<512) i512++;
else if (512<=index & index<640) i640++;
else if (640<=index & index<786) i786++;
else if (786<=index & index<896) i896++;
else if (896<=index & index<1024) i1024++;
else if (1024<=index & index<1152) i1152++;
else if (1152<=index & index<1280) i1280++;
else if (1280<=index & index<1408) i1408++;
else if (1408<=index & index<1536) i1536++;
Считаем количество попаданий index в различные диапазоны значений.
+183
#include "stdafx.h"
#include "windows.h"
#Define igra
int main1(int argc, CHAR* argv[])
{
...
}
int main2(int argc, CHAR* argv[])
{
...
}
http://www.gamedev.ru/code/forum/?id=19939+79
ArrayList<String> Stack = new ArrayList<String>(14);
ArrayList<String> ShuffledStack = new ArrayList<String>(14);
Stack.add(0,"a");
Stack.add(1,"b");
Stack.add(2,"c");
Stack.add(3,"d");
Stack.add(4,"e");
Stack.add(5,"f");
Stack.add(6,"e");
Stack.add(7,"g");
Stack.add(8,"h");
Stack.add(9,"j");
Stack.add(10,"k");
Stack.add(11,"l");
Stack.add(12,"o");
Stack.add(13,"m");
int size = Stack.size();
while(ShuffledStack.size() != size)
{
int r = (int)(Math.random()*(size));
if(!ShuffledStack.contains( Stack.get( r )))
ShuffledStack.add( Stack.get( r ));
}
> Еще более гнетет то что великого старину Доналда Кнута я так и не прочел. Дело в том что там большинство алгоритмов на математических формулах и основаны(бля, меня колбасит от такого)))...
Источник: http://pyha.ru/forum/topic/3831.0
+165
if ($flag == false) {
# на всякий случай
if (false == true) exit;
include «execute.php»;
}
На просторах инета... Какой ещё ВСЯКИЙ СЛУЧАЙ?
+164
function ubiyca() {
function pasha() {
// убийца паша
dead('машу'); // паша убивает машу
function masha() {
//убийца маша
dead('пашу'); // маша убивает пашу
}
}
function dead_ pasha_and_masha() {
//убиваем пашу и машу
dead('и пашу и машу');
}
}
Код знакомого, который пытается реализовать могилки на сайте.
function dead_ pasha_and_masha() {
//убиваем пашу и машу
dead('и пашу и машу');
}
Получается, что паша и маша убивает пашу и машу? оО
+166
// say this is some existing structure. And we want to use
// a list. We can tell it that the next pointer
// is apple::next.
struct apple {
int data;
apple * next;
};
// simple example of a minimal intrusive list. Could specify the
// member pointer as template argument too, if we wanted:
// template<typename E, E *E::*next_ptr>
template<typename E>
struct List {
List(E *E::*next_ptr):head(0), next_ptr(next_ptr) { }
void add(E &e) {
// access its next pointer by the member pointer
e.*next_ptr = head;
head = &e;
}
E * head;
E *E::*next_ptr;
};
int main() {
List<apple> lst(&apple::next);
apple a;
lst.add(a);
}
c++ страшный язык :) (часть вторая)
C++: Pointer to class data member: http://stackoverflow.com/questions/670734/c-pointer-to-class-data-member
Такие конструкции "E *E::*next_ptr;" без подготовки не осилить.
+180
; -------- мув в AX опкода команды UD2 --------
CODE:004051B0 mov al, 0Bh
CODE:004051B2 mov ah, 0Fh
CODE:004051B4 xchg al, ah
CODE:004051B6 push eax ; save opcode
CODE:004051B7 call sub_40A1E5
; -------- вис для отладки --------
; если зависли, то найден дубликат (жестко, но надежно :D )
CODE:0041C676 call hash_FindWord
CODE:0041C67B @@dbllock:
CODE:0041C67B jnc @@dbllock ; <- если хэш найден, то висим
; -------- ну и искомый баг --------
; неправильный цикл поиска последнего элемента списка
CODE:00401698 proc sub_401698
CODE:00401698 mov ecx, [dword_42944C]
CODE:0040169E jecxz loc_4016AA
CODE:004016A0 loc_4016A0:
CODE:004016A0 mov ecx, [ecx] ; ecx = next block
CODE:004016A2 and ecx, ecx
CODE:004016A4 jnz loc_4016A0
CODE:004016A6 mov eax, [ecx+8] ; <-- bag: ECX = 0
CODE:004016A9 retn
CODE:004016AA loc_4016AA:
CODE:004016AA mov eax, [dword_42A58E]
CODE:004016AF retn
CODE:004016AF endp
Искал баги в борландовском компиляторе. Нашел немало забавных моментов, три выкладываю.
+164
template < int Order, typename T >
struct PrefixSum {
static inline void update ( T* a ) throw () { *a += *(a-1); PrefixSum < Order-1, T > :: update( a+1 ); }
};
template < typename T >
struct PrefixSum < 1,T > {
static inline void update ( T* a ) throw () { *a += *(a-1); }
};
template < int P, int N, int Condition = 0 >
struct Bpn {
enum { value = N * ( Bpn < P-1, N-1, (N > P) > :: value - Bpn < P-1, N, (N > P-1) > :: value ) };
};
template < int P, int N > struct Bpn < P, N, !0 > { enum { value = 0 }; };
template < int P > struct Bpn < P, 0, 0 > { enum { value = P ? 0 : 1 }; };
template < int P > struct Bpn < P, 1, 0 > { enum { value = P & 1 ? 1 : -1 }; };
template < typename Ta, typename Tb, bool C > struct IfThenElse;
template < typename Ta, typename Tb > struct IfThenElse < Ta, Tb, true > { typedef Ta TRes; };
template < typename Ta, typename Tb > struct IfThenElse < Ta, Tb, false > { typedef Tb TRes; };
template < int K, int I = 1 >
struct MomentSeries {
typedef typename IfThenElse < MomentSeries<K,I+1>, MomentSeries<K,K>, (I<K) >::TRes SubT;
static inline double accumulate ( double const* psum ) throw () {
return Bpn < K, I > :: value * psum [ I + 1 ] + SubT :: accumulate ( psum );
}
};
template < int K >
struct MomentSeries < K, K > {
static inline double accumulate ( double const* psum ) throw () {
return Bpn < K, K > :: value * psum [ K + 1 ];
}
};
template < int Order >
struct MomentLoop {
static inline void assign ( double *moments, size_t momentStride, double const* psum ) throw() {
*(moments - momentStride) = MomentSeries < Order-1 > :: accumulate ( psum );
MomentLoopAssign < Order-1 > :: assign ( moments - momentStride, momentStride, psum );
}
};
template <>
struct MomentLoop < 1 > {
static inline void assign ( double *moments, size_t momentStride, double const* psum ) throw() {
moments [ 0 ] = MomentSeries < 1, 1 > :: accumulate ( psum );
*(moments - momentStride) = psum [ 1 ];
}
};
/**
* Function computes a series of geometric moments by prefix summation method:
* Zhou F., Kornerup P. Computing Moments by Prefix Sums. // VLSI Signal Proc. - 2000. - 25. - P. 5 - 17.
* @param data is first data elemet address.
* @param ndataItems is number of data items.
* @param dataStride is the number of elements between two neighbor data items,
* in case of simple array dataStride is equal to 1.
* @param moments is address of 0-order moment.
* @param momentStride is number of elements between two neigbor moment items,
* in case of consequtive moments placement, momentStride is equal to 1.
*/
template < int Order, class OutPolicy >
inline void psmoment ( double const* data,
size_t const ndataItems,
size_t const dataStride,
double* moments,
size_t const momentStride ) throw() {
double psum [ Order+1 ] = { 0 };
// Initialize prefix sum
for ( size_t i = ndataItems, j = ndataItems * dataStride; i; ) {
--i; j -= dataStride; psum [ 0 ] = data [ j ];
PrefixSum < Order, double > :: update ( psum+1 );
}
// convert psum to moment values
OutPolicy :: assign ( moments + Order * momentStride, momentStride, psum );
}
Вы - тестовая площадка, перед написанием статьи в пфп ;)