- 1
(lambda x:request.profile.role if request.profile.role!=5 else 4)(request.profile.role)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−100
(lambda x:request.profile.role if request.profile.role!=5 else 4)(request.profile.role)
+140
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100
int main()
{
do
{
int i,f,kol,z=1;
char s1[MAX],s2[MAX],*ch=" .!?",*s3[MAX];
fflush(stdin);
do{puts("Vvedite vash text.");
gets(s1);}while((s1[0]==' ')||(s1[1]=='\n')||(s1[0]=='\0'));
strcpy(s2,s1);
s3[0]=strtok(s2,ch);
for(i=1;s3[i]=strtok(NULL,ch);i++)
{
}
f=i;
puts("Otsortirovannue slova.");
for(i=0,kol=0;i<f;i++)
{
if((*(s3[i])=='A')||(*(s3[i])=='a'))
{
printf("%s ",s3[i]);
kol++;
z=0;
}
}
if(z)puts("slov nety. =(");
printf("\nKollichestvo slov na 'A' ili 'a': %d",kol);
puts("\nvash text.");
puts(s1);
printf("\n");
printf("dlya povtora nathmite lubyi klavishu. dlya vuhoda ESC.\n\n");
}
while(getch()!=27);
}
Моя первая работа) Оцените) Правда я не помню что она делает)
+132
#define LengthOfArrayInternal(a)(sizeof(a)/sizeof(a[0]))
#define is_array(x) _Generic((x), typeof((x)[0])[LengthOfArrayInternal(x)]:1, default: 0)
#define COMPILE_TIME_ASSERT(expr) char constraint[expr]
#define length_of_array(a) ({COMPILE_TIME_ASSERT(is_array(a)); LengthOfArrayInternal(a)})
Определение длины массива. gcc и с11 only.
Говно как известно рождается в споре:
http://govnokod.ru/12108#comment160631
+35
// стоит простая задача: удалить все узлы из списка
// чувак думает, как же ему это реализовать через задницу?
// и получилось же!
if (link * root = list.get_root()) {
link * next;
do {
next = root->next();
list.remove(next);
} while (root = next);
}
// неужели нельзя вот так, по-простому?
link * node = list.get_root();
while (node) {
link * next = node->next();
list.remove(node);
node = next;
}
+141
http://www.ubuntu.com/download/desktop
1. Открыть страницу в Firefox/Google-Chrome.
2. Сверху над кнопкой "Download" сменить с 32 бит на 64 бит.
3. Посмотреть внимательно на URL, откуда будет загружатся имидж.
Код, который это делает трудно понять без контекста.
+118
filename_size = strlen(dest_dir) + strlen(basename) + 6;
ctx.mtl_file = (char *) malloc(filename_size);
ctx.obj_file = (char *) malloc(filename_size);
sprintf(ctx.mtl_file, "%s/%s.mtl", dest_dir, basename);
Долго соображали, почему вылезает сегфолт во free...
+103
digits n = reverse $ map (`mod` 10) (takeWhile (/= 0) (iterate (`div` 10) n))
fromDigits l = sum $ zipWith (*) (reverse l) (map (10^) [0..])
isPalindromic x = digits x == (reverse $ digits x)
f :: Integer -> [[Integer]] -> [Integer] -> Int -> [[Integer]]
f x founded lookedup niter
| niter > 50 = [notlychers, [x] ++ lychers ++ lookedup, zs]
| nextX `elem` notlychers = [[x] ++ notlychers ++ lookedup, lychers, zs]
| nextX `elem` lychers = [notlychers, [x] ++ lychers ++ lookedup, zs]
| isPalindromic nextX = [[x] ++ notlychers ++ lookedup, lychers, zs]
| otherwise = f nextX founded (x : lookedup) (niter+1)
where nextX = x + fromDigits (reverse $ digits x)
notlychers = founded !! 0
lychers = founded !! 1
zs = founded !! 2
g :: [[Integer]] -> [[Integer]]
g founded = f (x-1) [xs, ys, [x-1]] [] 0
where x = zs !! 0
xs = founded !! 0
ys = founded !! 1
zs = founded !! 2
gg n = g [[],[],[n+1]]
isLycher n = null $ (gg n) !! 0
http://projecteuler.net/problem=55
http://projecteuler.net/thread=55
>i even haven't understood why it works :(
+1002
template<class _CharType>
bool check_arith(const _CharType* str)
{
for(; *str ; ++str)
for(unsigned long long j = 0x6165696F7579ull; j; j >>= 8)
if(((j & 0xFF) | 0x20) == (*str | 0x20))
return true;
return false;
}
Функция, которая проверяет, есть ли в слове гласные буквы латинского алфавита с учетом регистра.
+961
private class LinkedAction
{
public Action<Action<bool>> Action { get; set; }
public LinkedAction Next { get; set; }
public void Execute()
{
Action(s =>
{
if (s && Next != null) Next.Execute();
});
}
}
private static LinkedAction NewLinkedAction(LinkedAction link, Action<Action<bool>> action)
{
return new LinkedAction
{
Action = action,
Next = link
};
}
var action = GetCopytoTestActions(parameter)
.Reverse()
.Aggregate<Action<Action<bool>>, LinkedAction>(null, NewLinkedAction);
action.Execute();
+1006
class Worker
{
private:
char name[15];
double salary;
...
public:
Worker(char* n, double s)
{
...
if (s < 0)
salary = verSal(s);
else
salary = s;
...
}
char* getName()
{
char* t = new char[15];
strcpy(t, name);
return t;
}
private:
double verSal(double s)
{
do
{
cout << "Ошибка при вводе зарплаты. Введите зарплату: ";
cin >> s;
}
while (s < 0);
return s;
}
}
Вот ещё один пример из конспекта (это уже от другого преподавателя). Он, заявил, что в getName() о t "позаботится сборщик мусора". Просто он Java тоже читает...