- 1
Питушня #7
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Питушня #7
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
−1
Иногда вижу такие "вложенные списки" в Markdown:
1. text
1.1. text
1.2. text
1.2.1. text
1.2.2. text
1.2.3. text
А потом ещё удивляются, почему списки съезжают или показываются неправильно...
0
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <conio.h>
const int x_size(20), y_size(10); int x_pos(x_size/2+1); int y_pos(y_size/2+1);
enum border_types{lineNL, single, singleNL};
enum directions{UpLeft=1, UpRight, DownLeft, DownRight}dir;
void draw_border(enum border_types borders) {
do{
if(borders == single || borders == singleNL) break;
for(int i=0; i<x_size+1; i++)
putchar('#');
}while(false);
putchar('#');
if(borders == singleNL || borders == lineNL) std::cout << '\n';}
void display_update() {
system("cls");
draw_border(lineNL);
for(int i=1; i<=y_size; i++)
{
draw_border(single);
for(int j=1; j<=x_size; j++)
{
if(j == x_pos && i == y_pos)
{
putchar('x');
continue;
}
putchar(32);
}
draw_border(singleNL);;
}
draw_border(lineNL);
std::cout << "X: " << x_pos << "\tY: " << y_pos;}
void logic() {
switch(x_pos)
{
case 1:
if(dir == UpLeft) dir = UpRight;
if(dir == DownLeft) dir = DownRight;
break;
case x_size:
if(dir == UpRight) dir = UpLeft;
if(dir == DownRight) dir = DownLeft;
}
switch(y_pos)
{
case 1:
if(dir == UpLeft) dir = DownLeft;
if(dir == UpRight) dir = DownRight;
break;
case y_size:
if(dir == DownLeft) dir = UpLeft;
if(dir == DownRight) dir = UpRight;
}}
void move() {
switch(dir)
{
case UpLeft:
x_pos--;
y_pos--;
break;
case UpRight:
x_pos++;
y_pos--;
break;
case DownLeft:
x_pos--;
y_pos++;
break;
case DownRight:
x_pos++;
y_pos++;
}}
int main() {
srand(time(0));
rand();
switch(rand()%4+1)
{
case UpLeft:
dir = UpLeft;
break;
case UpRight:
dir = UpRight;
break;
case DownLeft:
dir = DownLeft;
break;
case DownRight:
dir = DownRight;
}
while(!kbhit())
{
display_update();
logic();
move();
}
return 0;}
Сорян, пришлось уплотнить фигурные скобки, чтобы код уместился в 100 строк.
+1
Top 5 most loved languages:
Rust: 86.1%
TypeScript: 67.1%
Python: 66.7%
Kotlin: 62.9%
Go: 62.3%
Top 5 most dreaded languages:
VBA: 80.4%
Objective-C: 76.6%
Perl: 71.4%
Assembly: 70.6%
C: 66.9%
Top 5 most wanted languages:
Python: 30.0%
JavaScript: 18.5%
Go: 17.9%
TypeScript: 17.0%
Rust: 14.6%
https://insights.stackoverflow.com/survey/2020#technology-most-loved-dreaded-and-wanted-languages-wanted
Миллионы мух не могут ошибаться.
+6
Сракер, не удаляй, пожалуйста, наши оффтопы.
0
Тест потерянных комментариев
0
class UnitedFigure : public Figure {
Figure &f1;
Figure &f2;
public:
UnitedFigure (Figure &_f1, Figure &_f2) : f1(_f1), f2(_f2) {}
double distance_to(const Point &p) const override {
return std::min(f1.distance_to(p), f2.distance_to(p));
}
}
Завезли ссылочные поля класса, это в каком стандарте?
Даже тестил когда то такое, наверное на C++03 и получал ошибку компилятора.
Я и не знал, что добавили такую прекрасную возможность выстрелить себе в ногу.
+2
Definition read_t key cont : Thread :=
call tx_context <- get_tx_context;
call cell <- get_cell key tx_context;
match cell.(cell_write) with
| Some v =>
do _ <- log (read key v);
cont v
| None =>
do v <- read_d key;
let tx_context' := set tx_cells <[key := cell]> tx_context in
do _ <- pd_set tx_context';
do _ <- log (read key v);
cont v
end.
Continuations are like violence, if they don't work then you're not using enough of them.
0
Хрюкни #7
._ __,
|\,../'\
,'. . `.
.-- '`.
( `' , ;
,`--' _, ,'\
,`.____ `.
/ `, |
' \, '
| / /`,
`, . ,` ./ |
' `. ,' |;,' ,@
______| | _________,_____jv______
`. `. ,'
,'_,','_,
`' `'
#1: (vanished) https://govnokod.xyz/_26863
#2: (vanished) https://govnokod.xyz/_26868
#3: https://govnokod.ru/26881 https://govnokod.xyz/_26881
#4: https://govnokod.ru/26896 https://govnokod.xyz/_26896
#5: https://govnokod.ru/26928 https://govnokod.xyz/_26928
#6: (vanished) https://govnokod.xyz/_26952
0
uint64_t stored_msg_id = _container_msg_id.get(ctrl_msg.sequence); // Получаем msg_id из мапы для связки сообщений
if (stored_msg_id)
proto_fill(ctrl_msg, stored_msg_id); // если он там был то новому сообщению даем этот msg_id
else
proto_fill(ctrl_msg); // Иначе формируем новый msg_id
// Отсылаем сообщение
...
// Если msg_id не был в _container_msg_id то произойдет попытка вставки msg_id полученного через proto_fill.
if (!stored_msg_id && !_container_msg_id.insert(ctrl_msg.sequence, ctrl_msg.msg_id))
{
DEBUG(L, 0, "[%p] Can't store request's control message id (%llu) in bunch map" \
", response's msg_id will differ", this, msg.msg_id);
}
С точки зрения читабельности кода, в последнем ветвлении говнокод?