- 1
- 2
- 3
- 4
- 5
- 6
inline uint32 pow(uint32 arg1, int agr2)
{
for (int i = 0; i < agr2; ++i)
arg1 *= arg1;
return arg1;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+129
inline uint32 pow(uint32 arg1, int agr2)
{
for (int i = 0; i < agr2; ++i)
arg1 *= arg1;
return arg1;
}
Возведение в степень.
+130
#define FOO /* a macro with a multiline comment
* gets the linecount wrong
*/
Splint will miscalculate line numbers after multi-line comments in macro definitions. For example,
+111
__flash unsigned char keyGenData[256*7]={
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+0*(1<<3)+0*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<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<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+0*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
Нарыл в институте.
Забивают цифры для показывания на светодиодной панельке 5x7 (если присмотритесь, можете увидеть картинку, образуемую нулями). Такой простыни 96 КБ.
+138
memset(cb->chars, cb->width * cb->height, ' ');
Мой однострочный эпик фейл.
+142
if(selected == 3){
if(count == 1){
displayIntResult(0);
}else{
if(count == 1){
displayIntResult(0);
}else{
// код
}
}
// код
}
Надо больше спать. Обнаружено после ночи кодинга
+130
for(int j =0;j<d[i]/2;++j){
char e[2] = {0,'\0'};
const char* g = &e[0];
e[0] = dict[i];
s0.append(g);
}
Нужен был const char*
+138
//
switch (cwin->cpref->shuffle) {
case TRUE:
last = g_list_last(cwin->cstate->rand_track_refs);
if ((!cwin->cstate->curr_rand_ref) || (last && (cwin->cstate->curr_rand_ref == last->data))){
path = get_next_unplayed_random_track(cwin);
if (!path)
rand_unplayed = TRUE;
}
else path = get_next_random_ref_track(cwin);
break;
case FALSE:
path = get_next_sequential_track(cwin);
if (!path) seq_last = TRUE;
break;
default:
break;
}
буль...
+128
Unsigned long int getset (void)
{unsigned long int a; int k; h=0;
While (‘<не конец файла>==<читать число в k>’);
{switch k
{case 1: h = h/0x 0001; break;
case 2: h = h/0x 0002; break;
case 3: h = h/0x 4; break;
case 4: h = h/0x 8; break;
case 5: h = h/0x 10; break;
case 6: h = h/0x 20; break;
case 7: h = h/0x 40; break;
case 8: h = h/0x 80; break;
…
case 30: h = h/0x 2000 0000; break;
case 31: h = h/0x 4000 0000; (- 1 на 31 месте) break;
case 32: h = h/0x 8000 0000; (- 1 на 32 месте) break;
}
}
return (h)
}
Мне кажется или весь смысл сводиться к h = h/2^(k-1)
+128
#ifndef __KERNEL__
/* Multicast groups - backwards compatiblility for userspace */
#define SELNL_GRP_NONE 0x00000000
#define SELNL_GRP_AVC 0x00000001 /* AVC notifications */
#define SELNL_GRP_ALL 0xffffffff
#endif
enum selinux_nlgroups {
SELNLGRP_NONE,
#define SELNLGRP_NONE SELNLGRP_NONE
SELNLGRP_AVC,
#define SELNLGRP_AVC SELNLGRP_AVC
__SELNLGRP_MAX
};
#define SELNLGRP_MAX (__SELNLGRP_MAX - 1)
Linux 3.3.0
include/linux/selinux_netlink.h
+133
#include <stdio.h>
float abs(float a) { return a > 0 ? a : -a; }
int main() {
float x, e, step = 1, summ = step;
int i = 0;
scanf("%f, %f", (printf("x, e: "), &x), &e);
do summ += (abs(step *= x / ++i) > e) ? step : 0; while (abs(step) > e);
printf("summ = %f\n", summ);
return 0;
}
вычисление суммы ряда (1 + x/1! + x^2/2! + ... + x^n/n!), с заданной точностью