- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
#define as ;while
int main(int argc, char* argv[])
{
int n = atoi(argv[1]);
do printf("n is %d\n", n) as ( n --> 0);
return 0;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 44
0
#define as ;while
int main(int argc, char* argv[])
{
int n = atoi(argv[1]);
do printf("n is %d\n", n) as ( n --> 0);
return 0;
}
0
.org 80h
data:
db "Hello, world!\n"
db 0h
start:
mov %bp @data
; jmp @.exit ;
.loop:
mov %al [%si + %bp]
inc %si
cmp %al 0h
int 5h ;KOKOKO make me port-mapped io;
jnz @.loop
.exit:
int 0h
32 31 44 41 54 41 3A 30 30 38 30 3B 53 54 41 52
54 3A 30 30 38 45 3B 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 48 65 6C 6C 6F 20 77 6F 72
6C 64 21 0A 00 02 06 80 00 03 0A 38 09 05 0C 0A
00 00 0B 05 0F 92 00 0B 00
добавил комментарии, теперь можно будет красиво рисовать фреймы (радуйтесь)
+1
#include <iostream>
using namespace std;
void Brezenhem(char **z, int x0, int y0, int x1, int y1)
{
int A, B, sign;
A = y1 - y0;
B = x0 - x1;
if (abs(A) > abs(B)) sign = 1;
else sign = -1;
int signa, signb;
if (A < 0) signa = -1;
else signa = 1;
if (B < 0) signb = -1;
else signb = 1;
int f = 0;
z[y0][x0] = '*';
int x = x0, y = y0;
if (sign == -1)
{
do {
f += A*signa;
if (f > 0)
{
f -= B*signb;
y += signa;
}
x -= signb;
z[y][x] = '*';
} while (x != x1 || y != y1);
}
else
{
do {
f += B*signb;
if (f > 0) {
f -= A*signa;
x -= signb;
}
y += signa;
z[y][x] = '*';
} while (x != x1 || y != y1);
}
}
int main()
{
const int SIZE = 25; // размер поля
int x1, x2, y1, y2;
char **z;
z = new char*[SIZE];
for (int i = 0; i < SIZE; i++)
{
z[i] = new char[SIZE];
for (int j = 0; j < SIZE; j++)
z[i][j] = '-';
}
cout << "x1 = "; cin >> x1;
cout << "y1 = "; cin >> y1;
cout << "x2 = "; cin >> x2;
cout << "y2 = "; cin >> y2;
Brezenhem(z, x1, y1, x2, y2);
for (int i = 0; i < SIZE; i++)
{
for (int j = 0; j < SIZE; j++)
cout << z[i][j];
cout << endl;
}
cin.get(); cin.get();
return 0;
}
https://prog-cpp.ru/brezenham/
спойлер: автор тян
0
constexpr std::size_t find(string_view str, char c) noexcept {
#if defined(__clang__) && __clang_major__ < 9 && defined(__GLIBCXX__) || defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
// https://stackoverflow.com/questions/56484834/constexpr-stdstring-viewfind-last-of-doesnt-work-on-clang-8-with-libstdc
// https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html
constexpr bool workaround = true;
#else
constexpr bool workaround = false;
#endif
if constexpr (workaround) {
for (std::size_t i = 0; i < str.size(); ++i) {
if (str[i] == c) {
return i;
}
}
return string_view::npos;
} else {
return str.find_first_of(c);
}
}
какой constexpr)))
0
.org 80h
fib:
push %b
push %d
push %c
mov %d [%sp + 8h]
mov %b 1h
mov %a 0h
.loop:
add %b %a
mov %c %a
mov %a %b
sub %a %c
dec %d
jnz @.loop
pop %c
pop %d
pop %b
ret
start:
mov %sp 2000h
push Fh
call @fib
pop
int 0h
один чел захотел написать для моей вмки компилятор лиспоподобного языка с некими S-выражениями и попросил пример вычисления ряда фибоначчи.
пришлось накопипастить с вики.
+2
struct S { struct Inner { }; };
template<int N> struct X;
auto refl = ˆS;
auto tmpl = ˆX;
void f() {
typename [:refl:] * x; // OK: declares x to be a pointer-to-S
[:refl:] * x; // error: attempt to multiply int by x
[:refl:]::Inner i; // OK: splice as part of a nested-name-specifier
typename [:refl:]{}; // OK: default-constructs an S temporary
using T = [:refl:]; // OK: operand must be a type
struct C : [:refl:] {}; // OK: base classes are types
template [:tmpl:]<0>; // OK: names the specialization
[:tmpl:] < 0 > x; // error: attempt to compare X with 0
}
и да, это приняли.
https://lists.isocpp.org/sg7/2021/04/0226.php
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2320r0.pdf
−2
not' = isInfinite . (1/)
−3
короче на новый год я ебанул гранатом по стене
его кровь лилась по мне
стул потом на видео крутил
вместе с видео убийства граната его я по каналам мутил
0
assert(not std::isnan(std::lerp(a, b, INFINITY))); // lerp here can be -inf
а вы говорите этим никто не пользуется
https://en.cppreference.com/w/cpp/numeric/lerp
−2
мдеее
мдеее