- 1
- 2
- 3
//! Set this value as an empty object.
/*! \post IsObject() == true */
GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; }
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+3
//! Set this value as an empty object.
/*! \post IsObject() == true */
GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; }
Парсер json'ок писали сверхлюди
https://github.com/Tencent/rapidjson/blob/master/include/rapidjson/document.h#L1188
+1
11 апреля - всемирный день анимешника
Всех поздравляем!!!
0
#include <iostream>
#include <cmath>
#include <iomanip>
#include "govno.h"
using namespace std;
void prnt_msg_start() {
cout << endl << "Программа решения квадратного уравнения по формуле: ";
cout << "aX^2 + bX + c = 0" << endl;
cout << setprecision(69) << endl; }
long double ks[] = {1, 2, 1, 3, 10, 2};
class SqrtQual {
const string msg_not_roots = "Нет корней!\n",
msg_any_number = "X -- любое число.\n",
msg_special_event = "Решение частного случая (bX + c = 0):\n",
msg_discrim = "Дискриминант = ";
long double A, B, C, D, X1, X2;
bool flag_roots = true, flag_equal_zero, flag_special_event, flag_not_equal_zero,
flag_any_number, flag_input = true, flag_abs_roots, flag_cubes_roots;
void init_fields();
string answer();
bool to_decide();
void to_start();
public:
SqrtQual ();
SqrtQual (int z);
SqrtQual (long double a, long double b, long double c);
};
void variation_task(int variant) {
if (!variant) SqrtQual obj;
else {
for (int i = 0, j = 0; i < 2; i++, j += 3) {
if (variant < 2) SqrtQual obj(ks[j], ks[j+1], ks[j+2]);
else SqrtQual obj(i);
}
}
}
int main() {
prnt_msg_start();
for (int i = 1; i < 3; i++) variation_task(i);
}
SqrtQual::SqrtQual(int z) {
if (z) flag_abs_roots = true;
else flag_cubes_roots = true;
to_start(); }
SqrtQual::SqrtQual() {
to_start(); }
SqrtQual::SqrtQual(long double a, long double b, long double c) {
A = a;
B = b;
C = c;
flag_input = false;
to_start(); }
void SqrtQual::to_start() {
cout << endl;
if (flag_input) Govnokod l_obj(A, B, C);
init_fields();
cout << answer(); }
void SqrtQual::init_fields() {
flag_any_number = ((A == 0) && (B == 0) && (C == 0));
flag_not_equal_zero = ((A == 0) && (B == 0) && (C != 0));
flag_special_event = ((A == 0) && (B != 0) && (C != 0));
bool equal_zero_v1 = ((A == 0) && (B != 0) && (C == 0));
bool equal_zero_v2 = ((A != 0) && (B == 0) && (C == 0));
flag_equal_zero = equal_zero_v1 || equal_zero_v2;
D = B*B - 4*A*C;
if ((D < 0) || flag_not_equal_zero)
flag_roots = false; }
string SqrtQual::answer() {
string tmp = msg_discrim + to_string(D) + "\n";
if (flag_special_event)
tmp = msg_special_event + tmp;
if (flag_any_number)
return msg_any_number;
else if (not flag_roots)
return msg_not_roots;
else {
bool flag_args = to_decide();
string root1("X = "), root2("X2 = ");
if (flag_abs_roots) {
root1 = "| X | = ", root2 = "| X2 | = ";
X1 = abs(X1), X2 = abs(X2);
}
else if (flag_cubes_roots) {
root1 = "X ^3 = ", root2 = "X2 ^3 = ";
X1 = pow(X1, 3), X2 = pow(X2, 3);
}
tmp += root1 + to_string(X1) + "\n";
if (flag_args)
tmp += root2 + to_string(X2) + "\n";
}
return tmp;
}
bool SqrtQual::to_decide() /* if true then two roots else one root */ {
if (flag_equal_zero) X1 = 0;
else if (flag_special_event) X1 = (-C/B); // special event
else if (D == 0) X1 = (-B/2*A);
else {
X1 = ((-B + sqrt(D)) / 2*A), X2 = ((-B - sqrt(D)) / 2*A);
return true; }
return false; }
Немного расширил функционал говнокода с учётом замечаний (в том числе и по архитектуре).
0
#include <iostream>
using namespace std;
int main()
{
cout << "is_same_v: " << std::is_same_v<int, const int> << endl;
}
https://en.cppreference.com/w/cpp/types/is_same
> If T and U name the same type (taking into account const/volatile qualifications), provides the member constant value equal to true. Otherwise value is false.
+3
var owl3L = $('.owl-carousel3 .js__product').length;
owl3L && $('.owl-carousel3').owlCarousel({
...
responsive: {
0: {
items: 1,
loop: owl3L > 1 ? true : false,
slideBy: 1
},
600: {
items: 2,
loop: owl3L > 2 ? true : false,
slideBy: 2
},
1000: {
items: 4,
loop: owl3L > 4 ? true : false,
slideBy: 4
}
}
});
Какой "Java Script"
+1
// File icontact.h
// Describes a contact in the address book
class IContact
{
public:
virtual ~IContact();
virtual void ...
...
void setContact(const QString& contact);
...
private:
QString m_contact;
// ... other fields ...
};
// File icontact.cpp
void IContact::setContact(const QString &contact)
{
m_contact = contact;
}
"Ну и че тут непонятного?" (Senior software developer, 8+ years of experience)
0
Как так получается, что после json_encode($massiv) у меня то "{}", то "[]"?
0
https://phpclub.ru/talk/threads/перевод-алгаритма-с-1с-в-пхп.52808/
+2
gr = love.graphics
win = love.window
lk = love.keyboard
require("button")
require("t")
function love.load()
local loading = {}
loading = serialize.load("records.lua")
font = gr.newFont("NotoSans.ttf",14)
mini = gr.newFont("NotoSans.ttf",10)
big = gr.newFont("NotoSans.ttf",30)
flag = nil --Flag = nil -menu, Flag = 1 -records, Flag = 2 -type game, Flag = 3 -type game standart, Flag = 4 -type game impulse, Flag = 5 -type game Invers, Flag = 6 -type game Unreal
kube = {x = 96, y = 196, colx = 8, coly = 8}
speed = 1
timer = 0
umber = {}
records = {{"Standart", 0},{"Impulse", 0},{"Invers", 0},{"Unreal", 0},{"XY diagonal", 0},{"Perpendiculars", 0}}
if loading and #loading > 0 then
for i = 1, #loading do
records[i][2] = loading[i]
end
end
score = 0
mb = {utton:create(200-font:getWidth(">Play<")/2,125,">Play<"),utton:create(200-font:getWidth(">Records<")/2,160,">Records<"),utton:create(200-font:getWidth(">Exit<")/2,195,">Exit<")}
tgb = {utton:create(200-font:getWidth(">Standart<")/2,60,">Standart<"),utton:create(200-font:getWidth(">Impulse<")/2,90,">Impulse<"),utton:create(200-font:getWidth(">Invers<")/2,120,">Invers<"),utton:create(200-font:getWidth(">Unreal<")/2,150,">Unreal<"),utton:create(200-font:getWidth(">XY diagonal<")/2,180,">XY diagonal<"),utton:create(200-font:getWidth(">Perpendiculars<")/2,210,">Perpendiculars<")}
back = utton:create(200-font:getWidth(" >Back< ")/2,300," >Back< ")
r = utton:create(200-font:getWidth(" >Restart< ")/2,250," >Restart< ")
end
local function restart()
kube = {x = 96, y = 196, colx = 8, coly = 8, speed = 350}
speed = 1
timer = 0
umber = {}
score = 0
toch = nil
end
My первый игра сделаная на love2d. Аж всплакнул.
−1
ЧисловойСимвол = ?(Найти("0123456789",СимволVIN)>0,Истина,Ложь);
Проверка на то, является ли "СимволVIN" числом