- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
#include <stdio.h>;
void check(int x, int y) {
if (2*x == y && y < 0 && 0 <= 2*x) {
puts("Impossible!");
}
}
int main() {
check(0x7F80007F, 0xFF0000FE);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
#include <stdio.h>;
void check(int x, int y) {
if (2*x == y && y < 0 && 0 <= 2*x) {
puts("Impossible!");
}
}
int main() {
check(0x7F80007F, 0xFF0000FE);
}
https://runtimeverification.com/blog/?p=257
When writing code for a specific compiler you can rely on the implementation-specified behavior, but signed overflow is still problematic. GCC promises that conversions between integer types will be reduced modulo the appropriate power of two when the value is not representable in the target type. This means that with GCC the conversion above will initialize var to -0x112234 on any architecture that GCC supports. However, only initialization and other conversions are safe. GCC still considers signed overflow in arithmetic as undefined behavior, and optimizes under the assumption that there will be no overflow. This can lead to apparently impossible results when signed values do overflow. Compiled with -O3, this program prints “Impossible!”.
By adding apparently-redundant casts to 2*x to give (int)(2*(unsigned int)x), the calculation becomes implementation-specified behavior from an out-of-range conversion instead of undefined behavior. While this code may not be portable between compilers, GCC now guarantees the “impossible” code will not be executed even with -O3.
0
import java.util.*;
public class Main
{
public static void main(String[] args)
{
two s = new two(25);
s.get();
}
}
class one
{
private int a;
one(int a)
{
this.a = a*2;
}
void get()
{
System.out.println(a);
}
}
class two extends one
{
void get()
{
get();
}
two(int a)
{
super(a);
}
}
Когда пытаешься вызвать функцию подкласса из класса
0
#!/system/bin/bash
indexOf()
{
echo "$1" "$2" | awk '{print index($1,$2)}'
}
str=$(wget -q -O - http://quote-citation.com/random)
str=${str//\"/} #??????? ???????
str=${str//\'/}
indexOf "$str" "inner"
Вот хуй поймёшь что хотели написать в этом коде
0
int r_k ( char *text, char *point, int d, int q ){
int n = strlen( text);
int m = strlen(point );
int h = (int) pow(d , m - 1 ) % q ;
int i;
int p = 0;
int t = 0;
int j ;
for(i = 0 ;i < m ; i++ ){
p = ( (d*p) + point[i]) % q;
t = ( (d*t) + text[i]) % q;
}
for(i = 0; i <= (n - m) ; i++ ){
if(p == t ){
for(j = 0 ; j < m ; j++)
if( text[i + j] != point[j])
break;
if ( j == m )
return i;
}
t = ( ( (d * (t - text[i] * h) ) + (text[i + m])) % q ) + q ;
}
return 0;
}
Даже " Касперский" сказал что это говно и молча удалил.
−2
for (int i = 0; i < components.Length; i++)
{
if (components[i]) components[i].GetComponent<ComponentScript>().ChangeComponent(CalculateCircuitScript.ComponentDataArray[components[i].GetComponent<ComponentScript>().lineNumber, components[i].GetComponent<ComponentScript>().elementNumber]);
}
Конструктор трёхфазных цепей на Unity3D
0
procedure TForm1.ProcListAdvancedCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
var DefaultDraw: Boolean);
var
TP:TprocessInfo;
xColor: TColor;
xRect: TRect;
xBitmap: TBitmap;
I, L, R: Integer;
begin
DefaultDraw:=False;
TP:=TProcessInfo(Item.SubItems.Objects[0]);
if (Item.Selected) then
begin
if Sender.Focused then
begin
if (FItemAtCursor <> -1) and (Item.Index = FItemAtCursor) then
xColor:=clNavy
else
xColor:=$00C56A31;
end
else
xColor:=$00D8E9EC
end
else
begin
if (TP.New<2) or (TP.Terminated<2) or (TP.Hidden) then
begin
if ShowDangerousProcesses then
if TP.Hidden then
xColor:=$00DBDBDB;
if ShowNewProcesses then
if TP.New <2 then
xColor:=$001DEB2D;
if ShowTerminatedProcesses then
if TP.Terminated < 2 then
xColor:=$001D2DEB;
end
else
if (Item.Index mod 2 = 1) then
xColor:=RGB(245,245,255)
else
xColor:=clWindow;
end;
Sender.Canvas.Brush.Color:=xColor;
DefaultDraw:=True;
if (Item.Selected) and Sender.Focused
then Sender.Canvas.Font.Color:=clWindow
else Sender.Canvas.Font.Color:=clWindowText;
Sender.Canvas.FillRect(Item.DisplayRect(drLabel));
DefaultDraw:=True;
Exit;
xRect:=Item.DisplayRect(drLabel);
Sender.Canvas.TextRect(xRect,xRect.Left+2,xRect.Top,Item.Caption);
for I:=0 to TListView(Sender).Columns.Count-1 do
begin
if TListView(Sender).Columns[TListView(Sender).Columns[I].ID].Width<=0 then Continue;
if (I=0) and (TListView(Sender).Columns[I].ID <> 0) then
begin
xRect.Left:=0;
xRect.Right:=xRect.Left+TListView(Sender).Columns.Items[TListView(Sender).Columns[I].ID].Width-1;
Sender.Canvas.FillRect(xRect);
Sender.Canvas.TextRect(xRect,xRect.Left+2,xRect.Top,Item.SubItems[TListView(Sender).Columns[I].ID-1]);
end
else
begin
if I>0 then
begin
xRect.Left:=xRect.Right+1;
xRect.Right:=xRect.Left+TListView(Sender).Columns.Items[TListView(Sender).Columns[I].ID].Width-1;
Sender.Canvas.FillRect(xRect);
if TListView(Sender).Columns[I].ID >0 then
Sender.Canvas.TextRect(xRect,xRect.Left+5,xRect.Top,Item.SubItems[Pred(TListView(Sender).Columns[I].ID)])
else
begin
L:=(Item.DisplayRect(drIcon).Right-Item.DisplayRect(drIcon).Left)+6;
Sender.Canvas.TextRect(xRect,xRect.Left+L,xRect.Top, Item.Caption)
end;
end;
end;
end;
Sender.Canvas.Brush.Color:=clWindow;
Sender.Canvas.FillRect(Item.DisplayRect(drIcon));
if Item.ImageIndex=-1 then Exit;
xBitmap:=TBitmap.Create;
TListView(Sender).SmallImages.GetBitmap(Item.ImageIndex,xBitmap);
ListView - великий и ужасный! - в режиме OwnerDraw.
Писал диспетчер процессов. Когда я разрешил прятать столбцы и включил свойство FullDrag, моя жизнь круто изменилась.
+2
return ( empty( $syndication_meta ) ? false : true );
0
import java.util.*;
public class Main
{
public static void main(String[] args) throws InterruptedException
{
StringBuilder s = new StringBuilder("#");
byte a=1;
boolean t=false;
while(true)
{
if(!t)
{
s.append("#");
a++;
}
if(a==40)
{
t=true;
}
if(a==0)
t=false;
if(t)
{
s.deleteCharAt(s.length()-1);
a--;
}
System.out.println(s);
Thread.sleep(100);
}
}
}
Красиво зато вышло
+2
public function sql ($sql) {
$r = array(
"'" => "", //ору с этого
'"' => '',
'DROP' => '',
'TRUNCATE' => '',
'SELECT' => '',
'UPDATE' => '',
'INSERT' => '',
'DELETE' => '',
'INSERT' => '',
'UNION' => ''
);
if($this->strposa(strtoupper($sql), array_keys($r))){
mail('[email protected]', 'Внимание!', 'Обнаружена попытка SQL инъекции: "'.$sql.'" с IP адреса: '.$_SERVER['REMOTE_ADDR']);
}
$sql = str_ireplace(array_keys($r), $r, $sql);
$sql = htmlspecialchars($sql);
$sql = strip_tags($sql);
$sql = stripslashes($sql);
return $sql;
}
−1
public function sendChat ($msg) {
if($this->isLogged()){
if($this->checkAd($this->sql($msg)) !== '' || $this->checkAd($this->sql($msg))[0] !== ' '){
$q = $this->db->row("SELECT * FROM `chat` WHERE `user` = '".intval($_SESSION['steamid'])."' ORDER BY `id` DESC LIMIT 1");
if($q->time+1 <= time()){
if($q->text != $this->checkAd($this->sql($msg))) {
$r = $this->db->query("INSERT INTO `chat` (`user`,`text`,`time`) VALUES ('".intval($_SESSION['steamid'])."', '".$this->sql($this->checkAd($msg))."', ".time().")");
return json_encode(array("success" => true,));
} else {
return json_encode(array("success" => false, "msg" => "flood"));
}
} else {
return json_encode(array("success" => false, "msg" => "flood"));
}
} else {
json_encode(array("success" => false, "msg" => "null_msg"));
}
} else {
return json_encode(array("success" => false, "msg" => "not_auth"));
}
}