- 1
Пиздец-оффтоп #44
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Пиздец-оффтоп #44
#14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
#15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
#16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
#17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
#18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
#19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
#20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
#21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
#22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
#23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
#24: https://govnokod.ru/27501 https://govnokod.xyz/_27501
#25: https://govnokod.ru/27521 https://govnokod.xyz/_27521
#26: https://govnokod.ru/27545 https://govnokod.xyz/_27545
#27: https://govnokod.ru/27572 https://govnokod.xyz/_27572
#28: https://govnokod.ru/27580 https://govnokod.xyz/_27580
#29: https://govnokod.ru/27738 https://govnokod.xyz/_27738
#30: https://govnokod.ru/27751 https://govnokod.xyz/_27751
#31: https://govnokod.ru/27754 https://govnokod.xyz/_27754
#32: https://govnokod.ru/27786 https://govnokod.xyz/_27786
#33: https://govnokod.ru/27801 https://govnokod.xyz/_27801
#34: https://govnokod.ru/27817 https://govnokod.xyz/_27817
#35: https://govnokod.ru/27822 https://govnokod.xyz/_27822
#36: https://govnokod.ru/27826 https://govnokod.xyz/_27826
#37: https://govnokod.ru/27827 https://govnokod.xyz/_27827
#38: https://govnokod.ru/27833 https://govnokod.xyz/_27833
#39: https://govnokod.ru/27862 https://govnokod.xyz/_27862
#40: https://govnokod.ru/27869 https://govnokod.xyz/_27869
#41: https://govnokod.ru/27933 https://govnokod.xyz/_27933
#42: https://govnokod.ru/27997 https://govnokod.xyz/_27997
#43: https://govnokod.ru/28042 https://govnokod.xyz/_28042
0
int main() {
ifstream input_file;
input_file.open("DATA");
string line;
while (getline(input_file, line)) {
size_t i = 0, j = 0;
string fname, sname;
float score;
char c = line[0];
while((c != ' ') && (j < line.size())) {
c = line[j];
j++;
}
fname = line.substr(i, j - i - 1);
i = j;
j += 1;
c = line[i];
while((c != ' ') && (j < line.size())) {
c = line[j];
j++;
}
sname = line.substr(i, j - i - 1);
i = j;
j += 1;
score = stof(line.substr(i, line.size()));
Data dat;
dat.fname = fname;
dat.sname = sname;
dat.score = score;
vec.push_back(dat);
}
const auto comp_fname = [](Data a, Data b){return a.fname >= b.fname;};
const auto comp_sname = [](Data a, Data b){return a.sname >= b.sname;};
const auto comp_score = [](Data a, Data b){return a.score >= b.score;};
const auto dcomp_fname = [](Data a, Data b){return a.fname < b.fname;};
const auto dcomp_sname = [](Data a, Data b){return a.sname < b.sname;};
const auto dcomp_score = [](Data a, Data b){return a.score < b.score;};
print(vec);
char choice = 0, order = 0;
cout << "Как сортировать (0 - Fфмилия, 1 - Iмя, 2 - CpegHuu_6aJlJl): ";
cin >> choice;
cout << "А в какмо порядке?7? (0 - по убыванию, 1 - по возрастанию)Ж ";
cin >> order;
if (choice == '0') {
if (order == '0') {
sort(vec.begin(), vec.end(), comp_fname);
} else {
sort(vec.begin(), vec.end(), dcomp_fname);
}
} else if (choice == '1') {
if (order == '0') {
sort(vec.begin(), vec.end(), comp_sname);
} else {
sort(vec.begin(), vec.end(), dcomp_sname);
}
} else if (choice == '2') {
if (order == '0') {
sort(vec.begin(), vec.end(), comp_score);
} else {
sort(vec.begin(), vec.end(), dcomp_score);
}
}
// и т.д. ...
Как вам? Зачёт? Незачёт? Удовлетворительно?
+1
https://habr.com/ru/post/655085/
эксель быстрее шарпов, шах и мат дотнетчики...
0
int (*parray)[sizeof *parray] = malloc(sizeof *parray);
0
Просто оффтоп #22
#1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
#2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
#3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
#4: (vanished) https://govnokod.xyz/_25472
#5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
#6: (vanished) https://govnokod.xyz/_26649
#7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
#8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
#9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
#10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
#11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
#12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
#13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
#14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
#15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
#16: https://govnokod.ru/27282 https://govnokod.xyz/_27282
#17: https://govnokod.ru/27319 https://govnokod.xyz/_27319
#18: https://govnokod.ru/27380 https://govnokod.xyz/_27380
#19: https://govnokod.ru/27500 https://govnokod.xyz/_27500
#20: https://govnokod.ru/27607 https://govnokod.xyz/_27607
#21: https://govnokod.ru/27951 https://govnokod.xyz/_27951
0
https://gitflic.ru/
https://gitflic.ru/
Ебаная паРаша.
0
# оутпут и инпут
"print": self.hprint, # вывод в консоль
"println": self.hprintln, # вывод в консоль с переносом строки
"input": self.hinput, # ввод с консоли
"inputln": self.hinputln, # ввод с консоли с новой строки
питонисты бушуют
0
http://mainisusuallyafunction.blogspot.com/2014/02/x86-is-turing-complete-with-no-registers.html
посмотрите в комменты
+4
class ProjectIssue(
UserAgentDetailMixin,
SubscribableMixin,
TodoMixin,
TimeTrackingMixin,
ParticipantsMixin,
SaveMixin,
ObjectDeleteMixin,
RESTObject,
):
0
/*
xdrv_96_blacklist.ino - Blacklist for Tasmota
SPDX-FileCopyrightText: 2022 Theo Arends
SPDX-License-Identifier: GPL-3.0-only
*/
#define USE_BLACKLIST
#ifdef USE_BLACKLIST
/*********************************************************************************************\
* Blacklist support
*
* Check language and user set latitude/longitude against blacklist table
\*********************************************************************************************/
#define XDRV_96 96
typedef struct {
int16_t latitude_tl; // - 8999 to 8999
int16_t longitude_tl; // -17999 to 17999
int16_t latitude_br;
int16_t longitude_br;
uint16_t lcid;
} tBlArray;
//const char BlacklistText[] PROGMEM = "Stop war - Free Ukrain|Stop war - Free Ukrain|";
const char BlacklistText[] PROGMEM = "Stop war, Free Ukrain";
// lat_tl lon_tl lat_br lon_br lcid
tBlArray BlArray[] { 5900, 3200, 5300, 4400, 1049, // Around Moscow
5450, 2633, 5280, 2900, 1049 // Around Minsk
};
uint8_t blist_show = 0;
void BListEverySecond(void) {
if (Rtc.utc_time < 1648771200) { // Only until 2022-04-01
if (0 == (TasmotaGlobal.uptime % 20)) { // Only every 20 seconds
if (TasmotaGlobal.power) { // Only if any power on
uint32_t latitude = Settings->latitude / 10000;
uint32_t longitude = Settings->longitude / 10000;
uint32_t count = sizeof(BlArray) / sizeof(tBlArray);
for (uint32_t i = 0; i < count; i++) {
// Currently only supports top-right quarter of the earth
if ((LANGUAGE_LCID == BlArray[i].lcid) && // Check language id
(latitude < BlArray[i].latitude_tl) && // Check user set latitude and longitude against table
(latitude > BlArray[i].latitude_br) &&
(longitude > BlArray[i].longitude_tl) &&
(longitude < BlArray[i].longitude_br)) {
// char bl_text[100];
// snprintf_P(bl_text, sizeof(bl_text), PSTR("Power0 0")); // Turn all power off - annoying
// snprintf_P(bl_text, sizeof(bl_text), PSTR("Restart 1")); // Restart - more annoying
// snprintf_P(bl_text, sizeof(bl_text), PSTR("Reset 1")); // Reset - disastrous
// ExecuteCommand(bl_text, SRC_IGNORE);
// char bl_text[100];
// AddLog(LOG_LEVEL_NONE, PSTR("**** %s ****"), GetTextIndexed(bl_text, sizeof(bl_text), i, BlacklistText));
AddLog(LOG_LEVEL_NONE, PSTR("**** %s ****"), BlacklistText);
blist_show = i +1; // Set GUI message id
break;
}
}
}
} else if (0 == (TasmotaGlobal.uptime % 10)) { // Only every 10 seconds
blist_show = 0; // Reset GUI message id after 10 seconds
}
}
}
void BListShow(bool json) {
if (blist_show) {
// char bl_text[100];
// WSContentSend_PD(PSTR("{s}**** %s ****{m}{e}"), GetTextIndexed(bl_text, sizeof(bl_text), blist_show -1, BlacklistText));
WSContentSend_P(PSTR("{s}**** %s ****{m}{e}"), BlacklistText);
}
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdrv96(uint8_t function) {
bool result = false;
switch (function) {
case FUNC_EVERY_SECOND:
BListEverySecond();
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
BListShow(0);
break;
#endif // USE_WEBSERVER
}
return result;
}
https://github.com/arendst/Tasmota/commit/98cbf2587a1a914bbd16996ebb48dd451d3da448