- 1
- 2
- 3
- 4
- 5
- 6
for(;++i <= n && std::cin >> a;)
if(a >= 1.0 && ++bigger && std::cout << i << ' ');
else
if(mx < a)
mx = a,
maxi = i;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+3
for(;++i <= n && std::cin >> a;)
if(a >= 1.0 && ++bigger && std::cout << i << ' ');
else
if(mx < a)
mx = a,
maxi = i;
Решил сдать задачи на cf, в итоге выдавил из себя вот такой вот цикл.
Очень лень было ставить скобочки.
+3
__fastcall OpenArray(T arg0, T arg1, T arg2, T arg3, T arg4, T arg5, T arg6,
T arg7, T arg8, T arg9, T arg10, T arg11, T arg12,
T arg13, T arg14, T arg15, T arg16, T arg17, T arg18)
{
Array = new T[Count = 19];
Array[0] = arg0;
Array[1] = arg1;
Array[2] = arg2;
Array[3] = arg3;
Array[4] = arg4;
Array[5] = arg5;
Array[6] = arg6;
Array[7] = arg7;
Array[8] = arg8;
Array[9] = arg9;
Array[10] = arg10;
Array[11] = arg11;
Array[12] = arg12;
Array[13] = arg13;
Array[14] = arg14;
Array[15] = arg15;
Array[16] = arg16;
Array[17] = arg17;
Array[18] = arg18;
}
Старый недобрый C++ Builder. Выше по коду еще 17 таких же конструкторов.
+1
chunksLst.erase(++it1);
+142
List<EntryChange> changes = new List<EntryChange>();
for (int index = 0;
index < partsContainer.transform.childCount;
++index)
{
if (partsContainer
.transform
.GetChild(index)
.GetComponent<castle_parts_container>()
.inSave()
==
true)
{
// id of current part on scene
int partId =
partsContainer.transform
.GetChild(index).gameObject
.GetComponent<castle_parts_container>()
.partIdentificator;
int partColor =
partsContainer.transform
.GetChild(index).gameObject
.GetComponent<castle_parts_container>()
.savedColor();
int partNumber =
partsContainer.transform
.GetChild(index).gameObject
.GetComponent<castle_parts_container>()
.savedNumber();
EntryChange change = new EntryChange();
change.original =
partsContainer.transform
.GetChild(index).gameObject;
change.target =
partPrefabs.Where(
x => x.GetComponent<castle_parts_container>().partIdentificator
==
partId
&&
x.GetComponent<castle_parts_container>().partColor
==
partColor
&&
x.GetComponent<castle_parts_container>().partNumber
==
partNumber
).First();
changes.Add(change);
Избыточный код с форматированием в стиле Маяковского
+81
procedure tmythread.execute;
procedure fillmemo;
begin
form1.memo1.lines.add('Some string');
end;
begin
synchronize(fillmemo); //[Error] Unit1.pas(54): There is no overloaded version of 'Synchronize' that can be called with these arguments
end;
Почему нельзя сделать вещи, сделанные "через анус", еще более "через анус"?
+168
// ==UserScript==
// @name no horses
// @match *://govnokod.ru/*
// @grant none
// @run-at document-start
// ==/UserScript==
var CONFIG = {
horses: [
"Horse2",
"PragramistOtBoga",
"anonimb84a2f6fd141",
],
autoDownVote: true,
};
var observer = new MutationObserver(observeCallback);
var config = {
childList: true,
subtree: true,
};
observer.observe(document, config);
function observeCallback(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes) {
Array.prototype.forEach.call(mutation.addedNodes, function(node) {
try {
if (node.nodeType === 1 && /^comments_\d+$/.test(node.id)) {
handleComments(node);
}
} catch (e) {
console && console.warn && console.warn(e);
}
});
}
});
}
function downVote(node, type) {
var sel;
switch (type) {
case "post": sel = ".vote-against"; break;
case "comment": sel = ".comment-vote-against"; break;
default: throw 42; break;
}
var el = node.querySelector(sel);
if (el) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, unsafeWindow,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
}
}
function handleComments(node) {
var comments = node.querySelectorAll(".entry-comment-wrapper");
Array.prototype.forEach.call(comments, function(comment) {
try {
handleComment(comment);
} catch (e) {
console && console.warn && console.warn(e);
}
});
}
function handleComment(node) {
var author = node.querySelector(".entry-author").textContent.trim();
if (CONFIG.horses.indexOf(author) != -1) {
node.style.opacity = 0.3;
node.style.maxHeight = "4em";
node.style.overflow = "scroll";
if (CONFIG.autoDownVote) {
downVote(node, "comment");
}
}
}
function handlePosts(node) {
var posts = node.querySelectorAll(".hentry");
var i;
for (i = 0; i < posts.length; i++) {
try {
handlePost(posts[i]);
} catch (e) {
console && console.warn && console.warn(e);
}
}
}
function handlePost(node) {
var author = node.querySelector(".author a:nth-child(2)").textContent.trim();
if (CONFIG.horses.indexOf(author) != -1) {
if (!/^\/\d+$/.test(document.location.pathname)) {
node.style.opacity = 0.3;
node.style.maxHeight = "4em";
node.style.overflow = "scroll";
}
if (CONFIG.autoDownVote) {
downVote(node, "post");
}
}
}
document.addEventListener("DOMContentLoaded", function() {
handleComments(document.body);
handlePosts(document.body);
});
Я так и не смог заставить MutationObserver срабатывать на новые элементы, появляющиеся во время загрузки страницы. Отсюда и костыль в последних строчках.
+64
import java.util.ArrayList;
public class Chapter19 {
/* find repeat chars in text (in all words of text)
* print repeat chars
*
*/
private String stringArray[] = { "Allocates ae neaw Setringa tehat",
"represeants tahe same saequence " };
final private String alfabetArray = "abcdefghijklmnopqrstuvwxyz";
private ArrayList <Character> repeatChars;
public void run() {
printStringArray();
repeatChars = new ArrayList<Character>();
extractRepeatChars();
if (!repeatChars.isEmpty()) {
printRepeatChars();
} else {
System.out.println("not repeat ");
}
}
private void printRepeatChars(){
System.out.println("");
for (char c : repeatChars) {
System.out.println(c);
}
}
private void printStringArray(){
System.out.println(" ");
for (String s : stringArray) {
System.out.println(s);
}
}
public String [][] parseStringArray() {
String wordsArray[][] = new String[stringArray.length][];
for (int i = 0; i < wordsArray.length; i++) {
wordsArray[i] = stringArray[i].split("\n|\t| ");
}
return wordsArray;
}
public int findRepeatCharInWordsArray(String [][]wordsArray, char c) {
for (int i = 0; i < wordsArray.length; i++) {
for (int j = 0; j < wordsArray[i].length; j++) {
if (wordsArray[i][j].indexOf(c) < 0) {
return 0; // zodyje c nerastas
}
}
}
return 1;
}
public void extractRepeatChars() {
String wordsArray[][] = parseStringArray();
for (char c : alfabetArray.toCharArray()) {
if (findRepeatCharInWordsArray(wordsArray, c) > 0) {
repeatChars.add(c);
}
}
}
} // end
chapter 19
0
https://mangalib.me/fisheye-placebo/v1/c1?page=3
именно поэтому я за «SSH-соединение»
−1
#include <boost/hana.hpp>
#include <boost/hana/ext/std/tuple.hpp>
#include <cstdint>
namespace hana = boost::hana;
using namespace hana::literals;
using hana::transform, hana::decltype_, hana::to_set, hana::type_c;
auto copy = [](uint8_t * in, uint8_t * out, auto n, auto s) {
n.times.with_index([&](auto x) {
if constexpr(x == s) {
++in;
} else {
*(uint16_t *)out = *(uint16_t *)in;
out +=2; in += 2;
}
});
return in;
};
auto f(uint8_t * in, uint8_t * out) {
return copy(in, out, 33_c, 15_c);
}
https://habr.com/ru/post/482834/#comment_21094618
> Простая задача, самый базовый вариант https://godbolt.org/z/5F5mt9 — повторите.
Очередные набросы крестоговна на хабр от царя.
Найдите UB.
0
Узнали? Согласны?
https://www.youtube.com/watch?v=0GIcP6xvW5Q