- 1
echo "Свет истины!";
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−6
echo "Свет истины!";
Дабы пролить свет истины на ваши слепы очи, я скажу что по факту ПХП самый уебанский язык на свете и больше всего подвергался разного рода хакам, из-за его уёбищности были потеряны миллиарды долларов компаний и посажено миллионы хакеров! Ruby пизже и такого не было, nodejs пиздат и такого не предвидется, python тоже крут и сложно взломать
−1
var data = { //Списочек с русскими названиями
"Рыбы": {
"Форель": {},
"Щука": {}
},
"Деревья": {
"Хвойные": {
"Лиственница": {},
"Ель": {}
},
"Цветковые": {
"Берёза": {},
"Тополь": {}
}
}
};
function createTree(container, data) { // Создание списка из объекта
let mainUL = document.createElement('ul'); //Начало списка
let findLI = function(item, UL) { //рекурсивная функция
for(let k in item) { //перебор
let LI = document.createElement('li'); //Новый элемент списка
LI.textContent = k; //Устанавливаем текст элементу
UL.appendChild(LI); //Добавляем элемент в список
if(Object.keys(item[k]).length > 0) { //Есть ли там ещё элементы?
let newUl = document.createElement('ul'); //Новый список
UL.appendChild(newUl); //Фигачим его в список
findLI(item[k], newUl); //Тут мы посылаем ссылку поэтому всё робит
}
}
}
findLI(data, mainUL); //ищем все элементы
container.appendChild(mainUL); //добавляем в контейнер список (в конец)
}
var container = document.getElementById('container'); //ищем контейнер
createTree(container, data); // создаём спсиок
Комментатор 80-го уровня.
Жду ваших комментариев ублюдки!
−2
editText_url = tk.Entry(root)
editText_url.bind(SEQ_FOCUS_IN, lambda e: editText_url.delete('0', 'end') if editText_url.get() == url_placeholder else "")
editText_url.bind(SEQ_FOCUS_OUT, lambda e: editText_url.insert(0, url_placeholder) if len(editText_url.get()) == 0 else "")
В tkinter нет EditText с плейсхолдером, выкручиваемся как можем!
А еще в лямбде нельзя использовать if, зато можно тернарный оператор. `else` здесь беесполезен~
0
#include "stdafx.h"
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<fstream>
#include<iomanip>
#include<algorithm>
//#include<algorithm>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
multimap<string, int> mp;
multimap<string, int>::iterator it;
multimap<string, int>::iterator mit;
pair<multimap<string,int>::iterator, multimap<string, int>::iterator> pt;
set<int>nset;
string word;
char c = ' ';
char s[256];
fstream inOut;
inOut.open("text.txt", ios::in);
for (int i = 1; i < 500; i++) {
inOut.getline(s, 256);
char* pch;
pch = strtok(s, " ,-:");
while (pch != NULL) {
word = string(pch);
transform(word.begin(), word.end(), word.begin(), ::tolower);
mp.insert(pair <string, int>(word, i));
//cout « pch «'\t'«i« endl;
pch = strtok(NULL, " ,-:");
}
}
inOut.close();
set<string>set;
string tmp;
for (mit = mp.begin(); mit != mp.end(); mit++) {
tmp = (*mit).first;
if (set.find(tmp) != set.end()) {
continue;
}
else {
set.insert(tmp);
cout<<setw(15) << tmp << '\t';
pt = mp.equal_range(tmp);
for (it = pt.first; it != pt.second; ++it) {
nset.insert(it->second);
}
//cout << nset.size() << " ";
for (it = pt.first; it != pt.second; ++it) {
cout << it->second << ' ';
}
nset.clear();
cout << endl;
}
}
system("pause");
return 0;
}
Программа считывает слова сортирует и выдаёт все номера строк где данное слово встречается
−1
#include <iostream>
#include <string>
#include <sstream>
#include <string.h>
#include <stdlib.h>
typedef std::ios_base& sibr;
typedef sibr (*StringType)(sibr);
int atoi_hod(const char a[], short int *offset)
{
short int numtype = (a[0]== '0')+((a[1]=='x')||(a[1]=='X'));
StringType st;
*offset = 0;
while(a[*offset]&&a[*offset]!='.') (*offset)=(*offset)+1;
switch (numtype)
{
case 0:
st = std::dec;
break;
case 1:
st = std::oct;
break;
case 2:
st = std::hex;
break;
}
int u;
std::istringstream(a)>>st>>u;
return u;
}
bool isIpv4String(const std::string &str)
{
size_t size = str.length();
bool result = size!=0;
if(result)
{
const char *c_str = str.c_str();
unsigned long int i = 0;
char sym;
do
{
sym = c_str[i++];
result = sym=='.'||(sym>='0'&&sym<='9')||!sym||(sym>='a'&&sym<='f')||(sym>='A'&&sym<='F')||sym=='x'||sym=='X';
}
while (sym&&result);
i = 0;
short int dotsOrTerm = 0, numbers = 0, offset;
while (result&&i<size)
{
int n = atoi_hod(&c_str[i], &offset);
result = n<256;
numbers += result;
i += offset;
result = result&&(c_str[i]=='.'||!c_str[i]);
i+=result;
dotsOrTerm += result;
}
result = (dotsOrTerm == 4)&&(numbers == 4);
}
return result;
}
int main()
{
std::string adress;
std::cin>>adress;
std::cout<<(isIpv4String(adress)?"TRUE":"FALSE")<<std::endl;
return 0;
}
По мотивам ГК #24055, наконец-то руки дошли.
−5
$this->types = array_keys(ArrayHelper::map($types, 'id', 'id'));
В проекте на Yii2
0
Кстати насколько я помню во многих (возможно и во всех - не знаю) языках рекурсии имеют ограничения по вложенности или как там называется.
Насколько я помню многие программы или как там их, удаляют рекурсивно.
Следовательно: Можно ли наебнуть?
Я тупой
+3
namespace CarsKursova
{
public static class Car
{
public static int x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
x11, x12, x13, x14, x15, x16, x17, x18, x19, x20,
x21, x22, x23, x24, x25, x26, x27, x28, x29, x30,
x31, x32, x33, x34, x35, x36, x37, x38, x39, x40,
x41, x42, x43, x44, x45, x46, x47, x48, x49, x50,
x51, x52, x53, x54, x55, x56, x57, x58, x59, x60,
x61, x62, x63, x64, x65, x66, x67, x68, x69, x70,
x71, x72, x73, x74, x75, x76, x77, x78, x79, x80,
x81, x82, x83, x84,
y1, y2, y3, y4, y5, y6, y7, y8, y9, y10,
y11, y12, y13, y14, y15, y16, y17, y18, y19, y20,
y21, y22, y23, y24, y25, y26, y27, y28, y29, y30,
y31, y32, y33, y34, y35, y36, y37, y38, y39, y40,
y41, y42, y43, y44, y45, y46, y47, y48, y49, y50,
y51, y52, y53, y54, y55, y56, y57, y58, y59, y60,
y61, y62, y63, y64, y65, y66, y67, y68, y69, y70,
y71, y72, y73, y74, y75, y76, y77, y78, y79, y80,
y81, y82, y83, y84;
public static string car = " ";
public static bool game_over = false;
public static bool fix = true;
public static int score = 0;
public static char[,] game_grond = new char[35, 29];
public static char[,] game_gr = new char[35, 29];
....
}
public static void RisovPole()
{
p = Console.CursorTop;
z = Console.CursorLeft;
Console.ForegroundColor = ConsoleColor.Cyan;
WriteAt("|*|", 29, 0);
WriteAt("|*|", 29, 1);
WriteAt("|*|", 29, 2);
WriteAt("|*|", 29, 3);
WriteAt("|*|", 29, 4);
WriteAt("|*|", 29, 5);
WriteAt("|*|", 29, 6);
WriteAt("|*|", 29, 7);
WriteAt("|*|", 29, 8);
WriteAt("|*|", 29, 9);
WriteAt("|*|", 29, 10);
WriteAt("|*|", 29, 11);
WriteAt("|*|", 29, 12);
WriteAt("|*|", 29, 13);
WriteAt("|*|", 29, 14);
WriteAt("|*|", 29, 15);
WriteAt("|*|", 29, 16);
WriteAt("|*|", 29, 17);
WriteAt("|*|", 29, 18);
WriteAt("|*|", 29, 19);
WriteAt("|*|", 29, 20);
WriteAt("|*|", 29, 21);
WriteAt("|*|", 29, 22);
WriteAt("|*|", 29, 23);
WriteAt("|*|", 29, 24);
WriteAt("|*|", 29, 25);
WriteAt("|*|", 29, 26);
WriteAt("|*|", 29, 27);
WriteAt("|*|", 29, 28);
WriteAt("|*|", 29, 29);
WriteAt("|*|", 29, 30);
WriteAt("|*|", 29, 31);
WriteAt("|*|", 29, 32);
WriteAt("|*|", 29, 33);
WriteAt("|*|", 29, 34);
WriteAt("-----------------------------+*|", 0, 35);
WriteAt("*******************************|", 0, 36);
WriteAt("-------------------------------+\n\n\n\n\n\n\n\n\n\n\n", 0, 37);
Console.ResetColor();
}
public static void carplins()
{
y1 = 27; x1 = 13; y22 = 31; x22 = 13;
y2 = 27; x2 = 14; y23 = 31; x23 = 14;
y3 = 27; x3 = 15; y24 = 31; x24 = 15;
y4 = 28; x4 = 13; y25 = 32; x25 = 13;
y5 = 28; x5 = 14; y26 = 32; x26 = 14;
y6 = 28; x6 = 15; y27 = 32; x27 = 15;
y7 = 29; x7 = 10; y28 = 33; x28 = 10;
y8 = 29; x8 = 11; y29 = 33; x29 = 11;
y9 = 29; x9 = 12; y30 = 33; x30 = 12;
y10 = 29; x10 = 13; y31 = 33; x31 = 13;
y11 = 29; x11 = 14; y32 = 33; x32 = 14;
y12 = 29; x12 = 15; y33 = 33; x33 = 15;
y13 = 29; x13 = 16; y34 = 33; x34 = 16;
y14 = 29; x14 = 17; y35 = 33; x35 = 17;
y15 = 29; x15 = 18; y36 = 33; x36 = 18;
y16 = 30; x16 = 10; y37 = 34; x37 = 10;
y17 = 30; x17 = 11; y38 = 34; x38 = 11;
y18 = 30; x18 = 12; y39 = 34; x39 = 12;
y19 = 30; x19 = 16; y40 = 34; x40 = 16;
y20 = 30; x20 = 17; y41 = 34; x41 = 17;
Тетрисные гонки в консоли.
По ссылке - дермомонстр на 400 строк - http://www.cyberforum.ru/csharp-beginners/thread2169797.html
+2
return{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
0
try
{
// ... code ...
}
catch (ErrorResponseException& ex) { throw; }
Documenting-with-code?