- 1
- 2
- 3
- 4
- 5
Компиляторами являются:
1. С++
2. Паскаль
3. Ассемблер
4. Unix
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+66
Компиляторами являются:
1. С++
2. Паскаль
3. Ассемблер
4. Unix
Какой-то жопоразрывающий тест по с++ из ивановской области
http://hashcode.ru/questions/398214/
+57
curBlock = &(game->codeblocks[getCurBlockId((*(JumpLine *)(curBlock->getLine())).getJumpName())]);
+60
const QStringList numbers = QString::fromUtf8("Ноль|" \
"Один|" \
"Два|" \
"Три|" \
"Четыре|" \
"Пять|" \
"Шесть|" \
"Семь|" \
"Восемь|" \
"Девять" \
).split('|');
+57
template <class T>
T checked_signed_add(T a, T b) {
if (a >= 0) {
if (b >= 0 && std::numeric_limits<T>::max() - a < b)
throw std::runtime_error("Integer overflow");
} else {
if (b < 0 && std::numeric_limits<T>::min() - a > b)
throw std::runtime_error("Integer overflow");
}
return a + b;
}
Кресты. Знаковые числа. Сложение.
http://ideone.com/qxyAoG
+57
static int lowercase(const char *s) {
return tolower(* (const unsigned char *) s);
}
Byte-fuck
+57
char val;
//...
switch(val)
{
case '0': mOn = true; break;
default: mOn = false; break;
}
+56
void split_int(int num)
{
int i1,i2,i3,i4,i5,i6,i7,i8,i9,MAX = 10;
for(i1 = 1; i1 < MAX; i1++)
{
if(i1 == num)
printf("%d = %d\r\n",i1,num);
for(i2 = 1; i2 < MAX; i2++)
{
if(i1 + i2 == num)
printf
(
"%d + %d = %d\r\n",
i1,i2,num
);
for(i3 = 1; i3 < MAX; i3++)
{
if(i1 + i2 + i3 == num)
printf
(
"%d + %d + %d = %d\r\n",
i1,i2,i3,num
);
for(i4 = 1; i4 < MAX; i4++)
{
if(i1 + i2 + i3 + i4 == num)
printf
(
"%d + %d + %d + %d = %d\r\n",
i1,i2,i3,i4,num
);
for(i5 = 1; i5 < MAX; i5++)
{
if(i1 + i2 + i3 + i4 + i5 == num)
printf
(
"%d + %d + %d + %d + %d= %d\r\n",
i1,i2,i3,i4,i5,num
);
for(i6 = 1; i6 < MAX; i6++)
{
if(i1 + i2 + i3 + i4 + i5 + i6 == num)
printf
(
"%d + %d + %d + %d + %d + %d = %d\r\n",
i1,i2,i3,i4,i5,i6,num
);
for(i7 = 1; i7 < MAX; i7++)
{
if(i1 + i2 + i3 + i4 + i5 + i6 + i7 == num)
printf
(
"%d + %d + %d +%d + %d + %d + %d = %d\r\n",
i1,i2,i3,i4,i5,i6,i7,num
);
for(i8 = 1; i8 < MAX; i8++)
{
if(i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 == num)
printf
(
"%d + %d + %d + %d + %d + %d + %d + %d = %d\r\n",
i1,i2,i3,i4,i5,i6,i7,i8,num
);
for(i9 = 1; i9 < MAX; i9++)
if(i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 == num)
printf
(
"%d + %d + %d + %d + %d + %d + %d + %d + %d = %d\r\n",
i1,i2,i3,i4,i5,i6,i7,i8,i9,num
);
}
}
}
}
}
}
}
}
printf("\r\n");
}
С одного известного форума.
+136
#include <stdint.h>
#include <Windows.h>
#include <intrin.h>
typedef long dt;
namespace {
dt InitializationIsInProgress = 0;
dt InitializationIsFinished = 0;
}
dt InterlockedLoad(dt volatile * t){
return InterlockedCompareExchange(t, 0, 0);
}
dt InterlockedAssign(dt volatile * t, dt v){
dt c = 0;
while (c = InterlockedCompareExchange(t, v, c));
}
void InitializeSystem(){
if (InterlockedLoad(&InitializationIsFinished) == 1)
return;
while (InterlockedCompareExchange(&InitializationIsInProgress, 1, 0) == 1) Sleep(0);
//__ReadWriteBarrier();
if (InterlockedLoad(&InitializationIsFinished) == 1)
return;
Work();
InterlockedAssign(&InitializationIsFinished, 1);
InterlockedAssign(&InitializationIsInProgress, 0);
}
Не судите строга. Воспользуюсь как пастебином. Если найдете ошибки - пришлю пирожок.
+137
#define SQR(x) ((x)*(x))
#define RANGE(x1, y1, x2, y2) (sqrt(SQR(x1-x2) + SQR(y1-y2)))
#define bestz z_b[b_iz]
#define bestv v_b[b_iv]
#define curz z_b[it]
#define curv v_b[i]
#define best_range (bestz.rast + RANGE(bestz.x, bestz.y, bestv.x, bestv.y) + bestv.rast)
#define current_range (curz.rast + RANGE(curz.x, curz.y, curv.x, curv.y) + curv.rast)
#define fci (l + ((r - l) / 3))
#define sci (r - ((r - l) / 3))
#define fc z_b[fci]
#define sc z_b[sci]
#define from v_b[i]
#define range_1 (from.rast + RANGE(from.x, from.y, fc.x, fc.y) + fc.rast)
#define range_2 (from.rast + RANGE(from.x, from.y, sc.x, sc.y) + sc.rast)
+131
std::string new_artifact()
{
if (one_in(2)) { // Generate a "tool" artifact
it_artifact_tool *art = new it_artifact_tool();
int form = rng(ARTTOOLFORM_NULL + 1, NUM_ARTTOOLFORMS - 1);
artifact_tool_form_datum *info = &(artifact_tool_form_data[form]);
art->create_name(info->name);
art->color = info->color;
art->sym = info->sym;
art->materials.push_back(info->material);
art->volume = rng(info->volume_min, info->volume_max);
art->weight = rng(info->weight_min, info->weight_max);
// Set up the basic weapon type
artifact_weapon_datum *weapon = &(artifact_weapon_data[info->base_weapon]);
art->melee_dam = rng(weapon->bash_min, weapon->bash_max);
art->melee_cut = rng(weapon->cut_min, weapon->cut_max);
art->m_to_hit = rng(weapon->to_hit_min, weapon->to_hit_max);
if( weapon->tag != "" ) {
art->item_tags.insert(weapon->tag);
}
// Add an extra weapon perhaps?
if (one_in(2)) {
int select = rng(0, 2);
if (info->extra_weapons[select] != ARTWEAP_NULL) {
weapon = &(artifact_weapon_data[ info->extra_weapons[select] ]);
art->volume += weapon->volume;
art->weight += weapon->weight;
art->melee_dam += rng(weapon->bash_min, weapon->bash_max);
art->melee_cut += rng(weapon->cut_min, weapon->cut_max);
art->m_to_hit += rng(weapon->to_hit_min, weapon->to_hit_max);
if( weapon->tag != "" ) {
art->item_tags.insert(weapon->tag);
}
std::stringstream newname;
newname << weapon->adjective << " " << info->name;
art->create_name(newname.str());
}
}
// CHOP is a sword, STAB is a dagger
if( art->item_tags.count( "CHOP" ) > 0 ) {
art->item_tags.insert( "SHEATH_SWORD" );
}
if( art->item_tags.count( "STAB" ) > 0 ) {
art->item_tags.insert( "SHEATH_KNIFE" );
}
art->description = string_format(
_("This is the %s.\nIt is the only one of its kind.\nIt may have unknown powers; try activating them."),
art->nname(1).c_str());
// Finally, pick some powers
art_effect_passive passive_tmp = AEP_NULL;
art_effect_active active_tmp = AEA_NULL;
int num_good = 0, num_bad = 0, value = 0;
std::vector<art_effect_passive> good_effects = fill_good_passive();
std::vector<art_effect_passive> bad_effects = fill_bad_passive();
// Wielded effects first
while (!good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
(num_good < 1 || num_bad < 1 || one_in(num_good + 1) ||
one_in(num_bad + 1) || value > 1)) {
if (value < 1 && one_in(2)) { // Good
int index = rng(0, good_effects.size() - 1);
passive_tmp = good_effects[index];
good_effects.erase(good_effects.begin() + index);
num_good++;
} else if (!bad_effects.empty()) { // Bad effect
int index = rng(0, bad_effects.size() - 1);
passive_tmp = bad_effects[index];
bad_effects.erase(bad_effects.begin() + index);
num_bad++;
}
value += passive_effect_cost[passive_tmp];
art->effects_wielded.push_back(passive_tmp);
}
// Next, carried effects; more likely to be just bad
num_good = 0;
num_bad = 0;
value = 0;
good_effects = fill_good_passive();
bad_effects = fill_bad_passive();
while (one_in(2) && !good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
((num_good > 2 && one_in(num_good + 1)) || num_bad < 1 ||
one_in(num_bad + 1) || value > 1)) {
if (value < 1 && one_in(3)) { // Good
int index = rng(0, good_effects.size() - 1);
passive_tmp = good_effects[index];
good_effects.erase(good_effects.begin() + index);
num_good++;
} else { // Bad effect
int index = rng(0, bad_effects.size() - 1);
passive_tmp = bad_effects[index];
bad_effects.erase(bad_effects.begin() + index);
num_bad++;
}
value += passive_effect_cost[passive_tmp];
art->effects_carried.push_back(passive_tmp);