- 1
IT Оффтоп #103
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
IT Оффтоп #103
#73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
#74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
#78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
#79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
#80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
#81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
#82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
#83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
#84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
#85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
#86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
#87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
#88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
#89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
#90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
#91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
#92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
#93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
#94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
#95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
#96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
#97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
#98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
#99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
#100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
#101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
#102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
0
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
typedef struct list list;
struct list
{
list* next;
uint32_t data;
};
#define ADD_LIST(ptr, val) \
do { \
(ptr)->next = (list *)alloca(sizeof(list)); \
(ptr)->next->data = val; \
(ptr)->next->next = NULL;\
} while (0)
// https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
#define INIT_LIST(val) \
({ \
list *INIT_LIST = (list *)alloca(sizeof(list)); \
INIT_LIST->data = val; \
INIT_LIST->next = NULL; \
INIT_LIST; \
})
int main(void)
{
list *a = INIT_LIST(5);
ADD_LIST(a,10);
ADD_LIST(a->next,15);
ADD_LIST(a->next->next,20);
ADD_LIST(a->next->next->next,25);
ADD_LIST(a->next->next->next->next,30);
for(list *ptr = a; ptr != NULL; ptr = ptr->next)
{
printf("%d ", ptr->data);
}
return EXIT_SUCCESS;
}
А можно ли в крестоговне так сделать без Сишного Препроцессора?
0
using System;
namespace MainNamespace
{
class SelectionSort
{
private static int FindSmallest(int[] arr)
{
int smallest = arr[0];
int smallestIndex = 0;
for (int i = 1; i < arr.Length; i++)
{
if (arr[i] < smallest)
{
smallest = arr[i];
smallestIndex = i;
}
}
return smallestIndex;
}
public static int[] ArraySort(int[] arr)
{
int[] newArr = new int[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
int smallestIndex = FindSmallest(arr);
int arrayBeginningIndex = i;
newArr[arrayBeginningIndex] = arr[smallestIndex];
arr[smallestIndex] = Int32.MaxValue;
}
return newArr;
}
}
class MainClass
{
const int sizeOfArr = 7;
static int FindMaxProduct(int[] arr)
{
int maxProduct = 1;
int firstIndex = 0;
int secondIndex = 1;
int lastIndex = sizeOfArr - 1;
int beforeLastIndex = sizeOfArr - 1 - 1;
int beforeBeforeLastIndex = sizeOfArr - 1 - 2;
if (arr[firstIndex] * arr[secondIndex] * arr[lastIndex] > arr[beforeLastIndex] * arr[beforeBeforeLastIndex] * arr[lastIndex])
{
maxProduct = arr[firstIndex] * arr[secondIndex] * arr[lastIndex];
}
else
for (int i = 0; i < 3; i++)
maxProduct *= arr[lastIndex - i];
return maxProduct;
}
static void Main()
{
int[] arr = new int[sizeOfArr] {-31, 54, -39, -34, 0, 56, 92};
arr = SelectionSort.ArraySort(arr);
Console.WriteLine( FindMaxProduct(arr) );
Console.ReadKey();
}
}
}
Есть массив с целыми числами. Найти в этом массиве самое большое произведение 3 чисел и вывести в консоль.
0
Тестовый Оффтоп #3
#1: https://govnokod.ru/26373 https://govnokod.xyz/_26373
#1: https://govnokod.ru/26611 https://govnokod.xyz/_26611
#1: https://govnokod.ru/26824 https://govnokod.xyz/_26824
#1: https://govnokod.ru/26850 https://govnokod.xyz/_26850
#2: https://govnokod.ru/27102 https://govnokod.xyz/_27102
+2
...
fun([N1, _N2], Trace) ->
?assert(
?strict_causality( #{?snk_kind := "Adding table to a shard", shard := _Shard, live_change := true}
, #{?snk_kind := "Shard schema change"}
, ?of_node(N1, Trace)
)),
?assert(
?strict_causality( #{?snk_kind := "Shard schema change", shard := _Shard}
, #{?snk_kind := "Restarting shard server", shard := _Shard}
, ?of_node(N1, Trace)
)),
%% Schema change must cause restart of the replica process and bootstrap:
{_, Rest} = ?split_trace_at(#{?snk_kind := "Shard schema change"}, Trace),
?assert(
?strict_causality( #{?snk_kind := "Restarting shard server", shard := _Shard}
, #{?snk_kind := state_change, to := bootstrap}
, Rest
))
end).
Немного galaxy-brain тестов
0
Пиздец-оффтоп #25
#1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
#2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
#3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
#4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
#5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
#5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
#6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
#7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
#8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
#9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
#10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
#11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
#12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
#13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
#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
+2
abstract class Department {
constructor(public name: string) {}
printName(): void {
print("Department name: " + this.name);
}
abstract printMeeting(): void; // must be implemented in derived classes
}
class AccountingDepartment extends Department {
constructor() {
super("Accounting and Auditing"); // constructors in derived classes must call super()
}
printMeeting(): void {
print("The Accounting Department meets each Monday at 10am.");
}
generateReports(): void {
print("Generating accounting reports...");
}
}
function main() {
let department: Department; // ok to create a reference to an abstract type
department = new AccountingDepartment(); // ok to create and assign a non-abstract subclass
department.printName();
department.printMeeting();
//department.generateReports(); // error: department is not of type AccountingDepartment, cannot access generateReports
print("done.");
}
Алилуя - я вам абстракты принес :)
+1
/* В отдельном файле */
function Skif_Email(auth,em) {
em = em.substring(3,em.length-3);
auth = auth.substring(4,auth.length-4);
document.write('<a href="mailto:',em,'" title="Защищён от спам-роботов">',auth,'</a>');
}
/* На странице */
<script type="text/javascript">Skif_Email('[email protected]', '[email protected]');</script>
Какая защита )))
0
IT Оффтоп #102
#72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
#73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
#74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
#78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
#79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
#80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
#81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
#82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
#83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
#84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
#85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
#86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
#87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
#88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
#89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
#90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
#91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
#92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
#93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
#94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
#95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
#96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
#97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
#98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
#99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
#100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
#101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
0
Хрюкни #11
._ __,
|\,../'\
,'. . `.
.-- '`.
( `' , ;
,`--' _, ,'\
,`.____ `.
/ `, |
' \, '
| / /`,
`, . ,` ./ |
' `. ,' |;,' ,@
______| | _________,_____jv______
`. `. ,'
,'_,','_,
`' `'
#1: (vanished) https://govnokod.xyz/_26863
#2: (vanished) https://govnokod.xyz/_26868
#3: https://govnokod.ru/26881 https://govnokod.xyz/_26881
#4: https://govnokod.ru/26896 https://govnokod.xyz/_26896
#5: https://govnokod.ru/26928 https://govnokod.xyz/_26928
#6: (vanished) https://govnokod.xyz/_26952
#7: https://govnokod.ru/26955 https://govnokod.xyz/_26955
#8: https://govnokod.ru/27043 https://govnokod.xyz/_27043
#9: https://govnokod.ru/27175 https://govnokod.xyz/_27175
#10: https://govnokod.ru/27472 https://govnokod.xyz/_27472