- 1
IT Оффтоп #143
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
IT Оффтоп #143
#113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
#114: https://govnokod.ru/27659 https://govnokod.xyz/_27659
#115: https://govnokod.ru/27665 https://govnokod.xyz/_27665
#116: https://govnokod.ru/27671 https://govnokod.xyz/_27671
#117: https://govnokod.ru/27675 https://govnokod.xyz/_27675
#118: https://govnokod.ru/27685 https://govnokod.xyz/_27685
#119: https://govnokod.ru/27701 https://govnokod.xyz/_27701
#120: https://govnokod.ru/27703 https://govnokod.xyz/_27703
#121: https://govnokod.ru/27710 https://govnokod.xyz/_27710
#122: https://govnokod.ru/27728 https://govnokod.xyz/_27728
#123: https://govnokod.ru/27729 https://govnokod.xyz/_27729
#124: https://govnokod.ru/27730 https://govnokod.xyz/_27730
#125: https://govnokod.ru/27732 https://govnokod.xyz/_27732
#126: https://govnokod.ru/27733 https://govnokod.xyz/_27733
#127: https://govnokod.ru/27737 https://govnokod.xyz/_27737
#128: https://govnokod.ru/27742 https://govnokod.xyz/_27742
#129: https://govnokod.ru/27747 https://govnokod.xyz/_27747
#130: https://govnokod.ru/27755 https://govnokod.xyz/_27755
#131: https://govnokod.ru/27766 https://govnokod.xyz/_27766
#132: https://govnokod.ru/27790 https://govnokod.xyz/_27790
#133: https://govnokod.ru/27828 https://govnokod.xyz/_27828
#134: https://govnokod.ru/27834 https://govnokod.xyz/_27834
#135: https://govnokod.ru/27839 https://govnokod.xyz/_27839
#136: https://govnokod.ru/27845 https://govnokod.xyz/_27845
#137: https://govnokod.ru/27857 https://govnokod.xyz/_27857
#138: https://govnokod.ru/27867 https://govnokod.xyz/_27867
#139: https://govnokod.ru/27887 https://govnokod.xyz/_27887
#140: https://govnokod.ru/27900 https://govnokod.xyz/_27900
#141: https://govnokod.ru/27914 https://govnokod.xyz/_27914
#142: https://govnokod.ru/27942 https://govnokod.xyz/_27942
+2
int f6(int* a,int k, double& min, int& n, int& count) {
int i;
min = a[0];//8
n = 0;
count = 0;
for (i = 0; i < k; i++) {
if (a[i] == 0) {
count += 1;
}
if (abs(10-abs(a[i])) < abs(min)) {
min = a[i];
n = i;
}
}
return 0;
}
Помогите!!Пожалуйста!!Надо найти ближайший элемент к 10ти и его номер, почему не работает??
+3
public getWay(path: string) {
const arrPath = path.slice(1).split('/');
arrPath.map(item => {
this.crumbs.push(MathcPath[item]);
this.crumbs = this.crumbs.filter(crumb => crumb);
});
}
Используем map в качестве forEach + зачем-то фильтруем полученный массив в каждой итерации.
Причем этот код можно записать в одну строку, которая еще и будет работать быстрее.
0
// @strict: true
// @lib: es2020
// @declaration: true
type BadFlatArray<Arr, Depth extends number> = {
obj: {
"done": Arr,
"recur": Arr extends ReadonlyArray<infer InnerArr>
? BadFlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
: Arr
}[Depth extends -1 ? "done" : "recur"]
}["obj"];
declare function flat<A, D extends number = 1>(
arr: A,
depth?: D
): BadFlatArray<A, D>[]
function foo<T>(arr: T[], depth: number) {
return flat(arr, depth);
}
function main() {
foo<number>([1.0, 2.0], 2);
}
спорим вы нихрена не поняли что это такое?
−1
Питушня #21
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: (vanished) https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
#14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
#15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
#16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
#17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
#18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
#19: https://govnokod.ru/27620 https://govnokod.xyz/_27620
#20: https://govnokod.ru/27816 https://govnokod.xyz/_27816
0
namespace Generics {
function swap<T>(arr: T[], i: number, j: number): void {
let temp: T = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
function sortHelper<T>(arr: T[], callbackfn?: (value1: T, value2: T) => number): T[] {
if (arr.length <= 0 || !callbackfn) {
return arr;
}
let len = arr.length;
// simple selection sort.
for (let i = 0; i < len - 1; ++i) {
for (let j = i + 1; j < len; ++j) {
if (callbackfn(arr[i], arr[j]) > 0) {
swap(arr, i, j);
}
}
}
return arr;
}
export function arraySort<T>(arr: T[], callbackfn?: (value1: T, value2: T) => number): T[] {
return sortHelper(arr, callbackfn);
}
}
function main() {
print("testGenerics")
let inArray = [4.0, 3.0, 4593.0, 23.0, 43.0, -1.0]
Generics.arraySort(inArray, (x: number, y: number) => { return x - y })
let expectedArray = [-1.0, 3.0, 4.0, 23.0, 43.0, 4593.0]
for (let i = 0; i < expectedArray.length; i++) {
assert(inArray[i] == expectedArray[i])
}
}
ну вот и все.. можно считать последний говнокод... подходит миссия к концу.... и ... потом заархивить все и положить на полочку
+1
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[4] = {1, 2, 3, 4};
int (*a_p1)[4] = (int (*)[4])a;
int (*a_p2)[4] = &a;
for(size_t i = 0; i < 4; ++i)
{
printf("%p -> %d; %p -> %d\n", &(*a_p1)[i], (*a_p1)[i], &(*a_p1)[i], (*a_p2)[i]);
}
return EXIT_SUCCESS;
}
Вот такой вывод:
0x7ffee4ebd950 -> 1; 0x7ffee4ebd950 -> 1
0x7ffee4ebd954 -> 2; 0x7ffee4ebd954 -> 2
0x7ffee4ebd958 -> 3; 0x7ffee4ebd958 -> 3
0x7ffee4ebd95c -> 4; 0x7ffee4ebd95c -> 4
+1
a = int(input('Введите число A: '))
b = int(input('Введите число B: '))
c = int(input('Введите число C: '))
d = int(input('Введите число D: '))
if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and d % 2 == 0:
print ('Все числа четные')
elif a % 2 != 0 and b % 2 == 0 and c % 2 == 0 and d % 2 == 0:
print ('Все числа четные, кроме числа А')
elif a % 2 == 0 and b % 2 != 0 and c % 2 == 0 and d % 2 == 0:
print ('Все числа четные, кроме числа B')
elif a % 2 == 0 and b % 2 == 0 and c % 2 != 0 and d % 2 == 0:
print ('Все числа четные, кроме числа C')
elif a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and d % 2 != 0:
print ('Все числа четные, кроме числа D')
elif a % 2 != 0 and b % 2 != 0 and c % 2 == 0 and d % 2 == 0:
print ('Числа C и D четные, а А и B нет')
elif a % 2 != 0 and b % 2 == 0 and c % 2 != 0 and d % 2 == 0:
print ('Числа B и D четные, а А и C нет')
elif a % 2 != 0 and b % 2 == 0 and c % 2 == 0 and d % 2 != 0:
print ('Числа B и C четные, а А и D нет')
# with B
elif a % 2 == 0 and b % 2 != 0 and c % 2 != 0 and d % 2 == 0:
print ('Числа A и D четные, а B и C нет')
elif a % 2 != 0 and b % 2 == 0 and c % 2 != 0 and d % 2 == 0:
print ('Числа B и D четные, а А и C нет')
elif a % 2 != 0 and b % 2 == 0 and c % 2 == 0 and d % 2 != 0:
print ('Числа B и C четные, а А и D нет')
elif a % 2 == 0 and b % 2 == 0 and c % 2 != 0 and d % 2 != 0:
print ('Числа A и B четные, а C и D нет')
elif a % 2 == 0 and b % 2 != 0 and c % 2 != 0 and d % 2 != 0:
print ('Все числа нечетные, кроме числа А')
elif a % 2 != 0 and b % 2 == 0 and c % 2 != 0 and d % 2 != 0:
print ('Все числа нечетные, кроме числа B')
elif a % 2 != 0 and b % 2 != 0 and c % 2 == 0 and d % 2 != 0:
print ('Все числа нечетные, кроме числа C')
elif a % 2 != 0 and b % 2 != 0 and c % 2 != 0 and d % 2 == 0:
print ('Все числа нечетные, кроме числа D')
else:
print ('Введите только целые числа')
−1
function foo(x = class { static prop: string }): string {
return undefined;
}
function main() {
foo(class { static prop = "hello" }).length;
print("done.");
}
ну что С/C++ скушали? а ты так можешь говнокодить?
0
Просто оффтоп #21
#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