- 1
Забаньте гостинхо.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−101
Забаньте гостинхо.
Гуестинхо
0
if (true === false)
не ну шоб наверняка
0
using System;
using System.Linq;
using s = System.String;
using i = System.Int32;
class Player
{
static i sgn(i x) => x < 0 ? -1 : x > 0 ? 1 : 0;
static s g(ref i z, i Z, s S)
{
i t = sgn(z - Z);
if (t < 0) z++;
else if (t > 0) z--;
return S[t + 1] + "";
}
static void Main()
{
var a = Console.ReadLine().Split().Select(i.Parse).ToArray();
i X = a[0], Y = a[1], x = a[2], y = a[3];
while (true)
{
Console.ReadLine();
Console.WriteLine(g(ref y, Y, "S N") + g(ref x, X, "E W"));
}
}
}
Поиск пути на плоскости от первой точки координат до второй. Выводит направление следующего передвижения.
+1
#include <iostream>
#include <functional>
#include <array>
#include <iterator>
template <class T>
class Filter : public std::iterator<
std::input_iterator_tag,
typename std::iterator_traits<T>::value_type,
typename std::iterator_traits<T>::difference_type,
typename std::iterator_traits<T>::pointer,
typename std::iterator_traits<T>::reference
>
{
private:
typedef typename std::iterator_traits<T>::value_type value_type;
std::function<bool(value_type)> m_predicate;
T m_begin, m_end;
value_type m_current;
public:
Filter(T t_begin, T t_end, std::function<bool(value_type)> t_predicate)
: m_begin(t_begin), m_end(t_end), m_predicate(t_predicate)
{
}
Filter<T>& begin()
{
return ++*this;
}
Filter<T>& end()
{
return *this;
}
value_type operator* ()
{
return m_current;
}
Filter<T>& operator++ ()
{
do {
m_current = *m_begin;
++m_begin;
} while (m_begin != m_end && !m_predicate(m_current));
return *this;
}
bool operator!= (Filter<T>& t_right)
{
return m_begin != t_right.m_end;
}
};
int main()
{
std::array<int, 10> arr{ {4, 35, 0, 23, 0, 0, 5} };
for (auto i : Filter<typename std::array<int,10>::iterator>(arr.begin(), arr.end(), [](int x){return x != 0;})) {
std::cout << i << " ";
}
}
−99
Прошу забанить всех на один год.
админа - бессрочно.
+2
https://i.yapx.ru/D3IPu.jpg
Как я вам?)
−1
function isSpam(comment) {
// quick and dirty filter agains guest spam
// it can reject normal links, but who cares...
if ((comment.user_id == 1) && comment.text.match('http://'))
return true;
if ((comment.user_id == 25580) && ((comment.text.match('^, http')) ||
(comment.text.match(', , http')) ||
(comment.text.match('<strong>')) ||
(comment.text.match('^<a href=')) ||
(comment.text.match('^comment[0-9]+,')) ||
(comment.text.match('storefocus')) ||
(comment.text.match('.*Хрюкни, свинособака')) ||
(comment.text.match('.*<span style')) ||
(comment.text.replace(/\s*/g, '').match('viagra|cialis|levitra')) ||
(comment.text.match('-[0-9a-fA-F]{4}\.pdf'))))
return true;
return false;
}
http://gcode.cx/ngk/#!/settings
Какой анскилл )))
+1
function getCartMiniViewDisplayString($cart_entries) {
$count = $cart_entries->getProductCount();
$suffix = "";
$remainder = $count % 10;
switch($remainder) {
case 1:
$suffix = " товар";
break;
case 2:
case 3:
case 4:
$suffix = " товара";
break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 0:
$suffix = " товаров";
break;
}
return $count . $suffix;
}
Мой, переписывать с if в лень.
+2
In [196]: n= namedtuple('A', ['a', 'b'])(1,2)
In [197]: n.index
Out[197]: <function A.index>
In [198]: n.count
Out[198]: <function A.count>
In [191]: n = namedtuple('A', ['index', 'count'])(1,2)
In [192]: n
Out[192]: A(index=1, count=2)
In [193]: n.
n.count n.index
In [193]: n.count
Out[193]: 2
In [194]: n.index
Out[194]: 1
Это же отсос, да?
0
enum {
#include "opcodes"
};
Хотел юзать один файл с перечислением и в "Си" и в "fasm", но только потом понял, что в "fasm" так не получится :(