- 1
- 2
- 3
- 4
void crash()
{
(( void(*)() )0)();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+146
void crash()
{
(( void(*)() )0)();
}
Good crash :D
+76
public class Sorting {
private static void swapElements(int[] arr, int index1, int index2) {
int temp = arr[index1];
arr[index1] = arr[index2];
arr[index2] = temp;
}
public static void mergeSort(int[] arr) {
if (arr.length == 1) {
return;
}
final int temp = (arr.length % 2 == 0) ? arr.length / 2 : (arr.length + 1) / 2;
int[] left = new int[temp];
int[] right = new int[arr.length / 2];
System.arraycopy(arr, 0, left, 0, temp);
System.arraycopy(arr, temp, right, 0, arr.length / 2);
Sorting.mergeSort(left);
Sorting.mergeSort(right);
Sorting.mergeSortHelper(arr, left, right);
}
private static void mergeSortHelper(int[] arr, int[] left, int[] right) {
int L = 0, R = 0;
boolean Ltop = false, Rtop = false;
for (int i = 0; i < arr.length; i++) {
if (L < left.length - 1 && R < right.length - 1) {
if (left[L] <= right[R]) {
arr[i] = left[L];
L++;
} else {
arr[i] = right[R];
R++;
}
} else if ((L == left.length - 1) ^ (R == right.length - 1)) {
if (L == left.length - 1) {
if ((left[L] <= right[R]) && !Ltop) {
arr[i] = left[L];
Ltop = true;
} else {
arr[i] = right[R];
R++;
}
} else {
if ((right[R] <= left[L]) && !Rtop) {
arr[i] = right[R];
Rtop = true;
} else {
arr[i] = left[L];
L++;
}
}
} else {
if (i < arr.length - 1) {
arr[i] = (left[L] < right[R]) ? left[L] : right[R];
} else {
arr[i] = (left[L] > right[R]) ? left[L] : right[R];
}
}
}
}
Реализация сортировки слиянием на Java
+76
class PseudoVamp {
public int num;
public boolean truevamp = false;
public int x;
public int y;
public int n1;
public int n2;
public int n3;
public int n4;
void breaknsort() {
n1 = num % 10;
n2 = num / 10 % 10;
n3 = num / 100 % 10;
n4 = num / 1000;
int tmp;
for (int i = 0; i < 4; i++) {
if (n1 > n2) {
tmp = n1;
n1 = n2;
n2 = tmp;
}
if (n2 > n3) {
tmp = n2;
n2 = n3;
n3 = tmp;
}
if (n3 > n4) {
tmp = n3;
n3 = n4;
n4 = tmp;
}
}
}
public PseudoVamp(int a, int b) {
x = a;
y = b;
num = x * y;
breaknsort();
}
}
public class Test {
static void checkvamp(PseudoVamp vamp) {
int x1 = vamp.x % 10;
int x2 = vamp.x / 10;
int y1 = vamp.y % 10;
int y2 = vamp.y / 10;
int tmp;
for (int i = 0; i < 4; i++) {
if (x1 > x2) {
tmp = x1;
x1 = x2;
x2 = tmp;
}
if (x2 > y1) {
tmp = x2;
x2 = y1;
y1 = tmp;
}
if (y1 > y2) {
tmp = y1;
y1 = y2;
y2 = tmp;
}
}
if (vamp.n1 == x1 && vamp.n2 == x2 && vamp.n3 == y1 && vamp.n4 == y2)
vamp.truevamp = true;
}
public static void main(String[] args) {
for (int i = 11; i < 100; i++) {
for (int j = 11; j < 100; j++) {
PseudoVamp v = new PseudoVamp(i, j);
if (v.num < 1000)
continue;
if (v.num > 9999)
return;
checkvamp(v);
if (v.truevamp)
System.out.println(v.x + " * " + v.y + " = " + v.num);
}
}
}
}
A vampire number has an even number of digits and is formed by multiplying a pair of numbers containing half the number of digits of the result. The digits are taken from the original number in any order. Pairs of trailing zeroes are not allowed. Examples include:
1260 = 21 * 60
1827 = 21 * 87
2187 = 27 * 81
Write a program that finds all the 4-digit vampire numbers.
w/o using of arrays.
+160
if (__captcha.ammount > 0) {
var captcha = new Array();
for (var i in __captcha.queue) {
captcha = __captcha.queue[i];
delete __captcha.queue[i];
break;
}
__captcha.ammount--;
__update();
return captcha;
}
+103
function TForm1.getyoutube(ss: string): string;
var
//Вылавливаем ссылку
i:integer;
pos:integer;
length1:integer;
ssylka:string;
pos_str:string;
//Удаляем ненужные символы
pos_str2:string;
pos2,pos23:integer;
ssc:char;
begin
//Вылавливаем ссылку если это ютубовская ссылка
if isitok('youtube.com',ss)=true then
begin
protect;
memo1.lines.Text:=idhttp1.Get(ss);
for i:=0 to memo1.Lines.Count do
begin
pos_str:=' img.src = '+#39;
pos:=AnsiPos(pos_str,memo1.Lines.Strings[i]);
if pos=1 then
begin
length1:=length(memo1.Lines.Strings[i])-length(pos_str)-2;
ssylka:=copy(memo1.Lines.Strings[i],pos+length(pos_str),length1);
end;
end;
ssc:=#160;
pos_str:='youtube.com';
pos:=AnsiPos(pos_str,ssylka);
delete(ssylka,pos+length(pos_str),1);
delete(ssylka,6,1);
delete(ssylka,7,1);
pos_str2:='youtube.com/';
pos2:=AnsiPos(pos_str,ssylka);
pos2:=pos2+length(pos_str2);
pos_str2:='?ip';
pos23:=AnsiPos(pos_str,ssylka);
delete(ssylka,pos2,pos2-pos23);
insert('videoplayback',ssylka,pos2);
result:=ssylka;
end
else
begin
protectoff;
form2.show;
form1.enabled:=false;
end;
protectoff;
end;
Очень старый способ скачать видео с YouTube
+160
#include <stdio.h>
#include <boost/typeof/typeof.hpp>
template<class T>
struct __macro
{
__declspec(thread) static T _;
};
template<class T>
T __macro<T>::_;
#define def(c) (__macro<typeof(c)>::_ = c)
#define acc(c) (__macro<typeof(c)>::_)
#define is_digit(x) (def(x),(acc(x) >= '0' && acc(x) <= '9') ? true : false)
#define is_bugit(x) ((x >= '0' && x <= '9') ? true : false)
int main()
{
char hj;
hj = '9';
printf("test->") && is_bugit(hj++) && printf("ok\n") || puts("no");
hj = '9';
printf("test->") && is_digit(hj++) && printf("ok\n") || puts("no");
}
+158
/*
-----------------------------------------------------------------
Формируем Карту Сайта и записываем в Кэш
-----------------------------------------------------------------
*/
function sitemap() {
global $rootpath, $realtime, $set;
$links_count = 140;
$file = $rootpath . 'files/cache/sitemap.dat';
if (file_exists($file) && filemtime($file) > ($realtime - 604800)) {
// Считываем ссылки из Кэша
return file_get_contents($file);
} else {
$out = '';
// Карта Форума
$req = mysql_query("SELECT * FROM `forum` WHERE `type` = 'r'");
if (mysql_num_rows($req)) {
$out .= '<b>Forum Map</b>' . "\r\n";
while ($res = mysql_fetch_assoc($req)) {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `refid` = '" . $res['id'] . "' AND `type` = 't' AND `close` != '1'"), 0);
if ($count) {
$text = html_entity_decode($res['text']);
$text = mb_substr($text, 0, 30);
// Подсчитываем число блоков ссылок
$pages = ceil($count / $links_count);
if($pages > 1){
for($i = 0; $i < $pages; $i++){
$out .= '<br /><a href="' . $set['homeurl'] . '/sitemap/forum.php?id=' . $res['id'] . '&p=' . $i . '">' . functions::checkout($text) . ' (part ' . ($i + 1) . ')</a>' . "\r\n";
}
} else {
$out .= '<br /><a href="' . $set['homeurl'] . '/sitemap/forum.php?id=' . $res['id'] . '">' . functions::checkout($text) . '</a>' . "\r\n";
}
}
}
}
// Карта Библиотеки
$req = mysql_query("SELECT * FROM `lib` WHERE `type` = 'cat' AND `ip` = '0'");
if (mysql_num_rows($req)) {
$out .= '<br /><br /><b>Library Map</b>' . "\r\n";
while ($res = mysql_fetch_assoc($req)) {
$text = html_entity_decode($res['text']);
$text = mb_substr($text, 0, 30);
$out .= '<br /><a href="../library/index.php?id=' . $res['id'] . '">' . functions::checkout($text) . '</a>' . "\r\n";
}
}
if (!empty($out)) {
// записываем Кэш ссылок
if (!file_put_contents($file, $out)) {
return 'Cache file write error!';
}
return $out;
} else {
return false;
}
}
}
/*
-----------------------------------------------------------------
Показываем карту сайта
-----------------------------------------------------------------
*/
if (!defined('_IN_JOHNCMS')) {
define('_IN_JOHNCMS', 1);
require('../incfiles/core.php');
require('../incfiles/head.php');
echo '<div class="menu">' . sitemap() . '</div>';
require('../incfiles/end.php');
} else {
echo '<div class="menu"><div class="sitemap">' . sitemap() . '</div></div>';
}
JohnCMS 4, sitemap/index.php
Этот движок, кстати, почти самый распространнённый в wap
+146
logit("e", "%s No Menu! Wait 5 minutes and try again.\n", whoami);
for(j=0;j<60;j++) {
sleep_ew( 5000 ); /* wait around */
}
sgram из earthworm
+162
$res = $db->loadResult();
if($res); else return false;
if($res!=$user->id) return false;
return true;
+144
void method() {
if(true) return;
}
только что встретилось, всем коллективом ржали
немного классики, что бы не забывали.
однозначно поле для действий, но все равно забавно