-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+74
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
public class Encoder {
public static void encode(final OutputStream out, Node node) throws IOException {
node.accept(new NodeVisitor() {
@Override
public void string(StringNode node) {
byte[] value = node.toByteArray();
out.write(Integer.toString(value.length).getBytes(Constants.CHARSET));
out.write(':');
out.write(value);
}
// ... другие методы для других типов нод ...
}
}
}
Решил поменять в паре-тройке модулей пачки ифов на паттерн visitor... И получил пинка от жабы ;(
write() кидает IOException, а значит и метод string() в анонимном классе тоже должен кидать, и метод string() в интерфейсе NodeVisitor тоже... Но ведь соседним посетителям этот IOException нахер не сдался...
Checked exceptions - зло.
bormand,
12 Октября 2013
-
+32
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
#include <iostream>
void f(char c) { std::cout << "f(char)" << std::endl; }
void f(signed char c) { std::cout << "f(signed char)" << std::endl; }
void f(unsigned char c) { std::cout << "f(unsigned char)" << std::endl; }
int main()
{
f('a');
f((signed char)('a'));
f((unsigned char)('a'));
return 0;
}
илитный ресурс сегодня мне раскрыл глаза на очередное крестоблядство керниган-гай-ричи-блядство:
с:
The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.
Irrespective of the choice made, char is a separate type from the other two and is not compatible with either.
с++:
Characters can be explicitly declared unsigned or signed. Plain char, signed char, and unsigned char are three distinct types.
defecate-plusplus,
08 Октября 2012
-
+26
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
result.push_back(TVector<2>
(
(A-√(D))/C,
(E-Line.K()*√(D))/C
));
result.push_back(TVector<2>
(
(A+√(D))/C,
(E+Line.K()*√(D))/C
));
LispGovno,
31 Августа 2012
-
+141
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
...
ASSERT( sizeof(L"SystemPartition") <= sizeof(nameBuffer) );
/* Китайский код? Или по другому нельзя было запихнуть строку в ентот массив? */
nameBuffer[0] = L'S';
nameBuffer[1] = L'y';
nameBuffer[2] = L's';
nameBuffer[3] = L't';
nameBuffer[4] = L'e';
nameBuffer[5] = L'm';
nameBuffer[6] = L'P';
nameBuffer[7] = L'a';
nameBuffer[8] = L'r';
nameBuffer[9] = L't';
nameBuffer[10] = L'i';
nameBuffer[11] = L't';
nameBuffer[12] = L'i';
nameBuffer[13] = L'o';
nameBuffer[14] = L'n';
nameBuffer[15] = L'\0';
nameString.MaximumLength = sizeof(L"SystemPartition");
nameString.Length = sizeof(L"SystemPartition") - sizeof(WCHAR);
status = NtSetValueKey(setupHandle,
&nameString,
TITLE_INDEX_VALUE,
REG_SZ,
volumeNameString.Buffer,
volumeNameString.Length + sizeof(WCHAR)
);
...
В Мелкософт китайцев пригласили?
Кусок кода ядра Шindoшs ИТ
файл ioinit.c, строка 3312
Destinat1on,
16 Июня 2012
-
+107
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
begin
writeln('Enter 1st number');
readln(a);
writeln('Enter 2st number');
readln(b);
writeln('Enter 3st number');
readln(c);
if a = b then if a = c then if b = c then ;
writeln('numbers are');
if a > b then if a = c then if b < c then
writeln('a Equally c and it is more b') ;
if a = b then if a > c then if b > c then
writeln('a Equally b and it is more c') ;
if a < b then if a < c then if b = c then
writeln('b Equally c and it is more a') ;
if a > b then if a > c then if b > c then
writeln('a it is more ') ;
if a > b then if a > c then if b < c then
writeln('a it is more ') ;
if a > b then if a > c then if b = c then
writeln('a it is more ') ;
if a < b then if a = c then if b > c then
writeln('b it is more ') ;
if a < b then if a > c then if b > c then
writeln('b it is more ') ;
if a < b then if a < c then if b > c then
writeln('b it is more ') ;
if a = b then if a < c then if b < c then
writeln('c it is more ') ;
if a > b then if a < c then if b < c then
writeln('c it is more ') ;
if a < b then if a < c then if b < c then
writeln('c it is more ') ;
Такое выдал один из моих учеников в 10м классе после того, как отказался учится рисовать блок-схемы и сказал, что сразу сможет писать. Задание заключалось в том, чтобы программа выводила большее из 3х введенных пользователем чисел.
Rage,
20 Января 2012
-
+953
- 1
- 2
- 3
- 4
- 5
- 6
- 7
var result = System.Windows.Forms.MessageBox.Show("Ви дійсно бажаєте видалити платника?", "Видалення платників", System.Windows.Forms.MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{
DeleteWithoutRedirect(ReducingPayerID);
red_pay_list.RemoveAt(e.RowIndex);
}
это Code-Behind aspx страницы
Это писал "большой начальник" на укрПочте. Берегитесь Позывая. Он настолько суров, что гавнокодит сразу на 3 языках
bercerker,
06 Октября 2011
-
+164
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
inline ~Scene() {
while( boxList.size() > 0 ) {
boxList.erase( boxList.begin() );
}
while( sphereList.size() > 0 ) {
sphereList.erase( sphereList.begin() );
}
while( lightList.size() > 0 ) {
lightList.erase( lightList.begin() );
}
}
http://www.gamedev.ru/code/forum/?id=136478&page=6#m82
CPPGovno,
21 Сентября 2011
-
+164
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
ULONG LCard791::SetChn(int _gain,int _channel)
{
ULONG ret;
if(isDiff)
ret=_channel&15;
else
{
ret=_channel&31;
ret|=1<<5;
}
int gain;
switch(_gain)
{
case 1:
gain=0;
break;
case 2:
gain=1;
break;
case 4:
gain=2;
break;
case 8:
gain=3;
break;
case 16:
gain=4;
break;
case 32:
gain=5;
break;
case 64:
gain=6;
break;
case 128:
gain=7;
break;
default:
gain=0;
}
ret|=gain<<6;
return(ret);
}
Есть у нас один мужик, которые такие шедевры творит. Хакер сновидений, РАГ - мы с тобой!
phys-tech,
02 Сентября 2011
-
+131
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
if (comboBox1.SelectedItem.ToString() == "VISA")
{
pictureBox7.Visible = false;
pictureBox6.Visible = false;
pictureBox5.Visible = false;
pictureBox4.Visible = false;
pictureBox3.Visible = false;
pictureBox2.Visible = false;
pictureBox1.Visible = true;
}
if (comboBox1.SelectedItem.ToString() == "MasterCard")
{
pictureBox7.Visible = false;
pictureBox6.Visible = false;
pictureBox5.Visible = false;
pictureBox4.Visible = false;
pictureBox3.Visible = false;
pictureBox1.Visible = false;
pictureBox2.Visible = true;
}
+ ещй пять такие проверок. Ну не умеет человек PictureBox.Image пользоваться.
Killster,
16 Мая 2011
-
+162
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
/*
-----------------------------------------------------------------
Маскировка ссылок в тексте
-----------------------------------------------------------------
*/
function antilink($var) {
$var = preg_replace('~\\[url=(https?://.+?)\\](.+?)\\[/url\\]|(https?://(www.)?[0-9a-z\.-]+\.[0-9a-z]{2,6}[0-9a-zA-Z/\?\.\~&_=/%-:#]*)~', '###', $var);
$var = strtr($var, array (
'.ru' => '***',
'.com' => '***',
'.biz' => '***',
'.cn' => '***',
'.in' => '***',
'.net' => '***',
'.org' => '***',
'.info' => '***',
'.mobi' => '***',
'.wen' => '***',
'.kmx' => '***',
'.h2m' => '***'
));
return $var;
}
JohnCMS 4, incfiles/classes/functions.php
NadiaVita,
28 Декабря 2010