- 1
- 2
- 3
- 4
fm.bottom += ( tempBottom - fm.bottom );
fm.descent += ( tempDescent - fm.descent );
fm.ascent += ( tempAscent - fm.ascent );
fm.top += ( tempTop - fm.top );
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+78
fm.bottom += ( tempBottom - fm.bottom );
fm.descent += ( tempDescent - fm.descent );
fm.ascent += ( tempAscent - fm.ascent );
fm.top += ( tempTop - fm.top );
+145
#include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;
int main()
{
int wc,cnt=0,maxp=0,minp=2147483647,maxn=-2147483648,minn=0,pos=0,neg=0,zf=0;
fstream(f);
f.open("input.txt",ios::in);
while (!f.eof())
{
if(!zf) zf--;
wc=0;
f >>wc;
if (wc>0) { if (maxp<wc) maxp=wc; if (minp>wc) minp=wc; pos++; }
else {if (minn>wc) minn=wc; if (maxn<wc&&wc)maxn=wc; if (!wc) zf+=2; else neg++; }
}
if (pos>1 && neg>1)
if ((float)maxp/minp > (float)minn/maxn) cout<<maxp<<"/"<<minp<<"="<<(float)maxp/minp;
else cout<<minn<<"/"<<maxn<<"="<<(float)minn/maxn;
if (pos>1 && neg<2) cout<<maxp<<"/"<<minp<<"="<<(float)maxp/minp;
if (pos<2 && neg>1) cout<<minn<<"/"<<maxn<<"="<<(float)minn/maxn;
if (pos<=1 && neg<=1)
if(zf) if(pos) cout<<"0/"<<minp<<"=0";else cout<<"0/"<<minn<<"=0";
else if ((float)maxp/maxn>(float)maxn/maxp)cout<<maxp<<"/"<<maxn<<"="<<(float)maxp/maxn;
else cout<<maxn<<"/"<<maxp<<"="<<(float)maxn/maxp;
if (pos+neg+zf<=1) cout<<"No solution!";
f.close();
getch();
return 0;
}
Задача 2-ого курса: "в массиве целых числел найти два таких числа, чтобы их частное было максимальным ( O(n) )"
И ее решение -.- Особо доставляет название переменных
+145
return !!$this->db->where('id', $for_id)->update($for, $row);
ояебал, у них наверное где-то склад с веществами
+165
function loadtitle($array) { //Функция установки meta-параметров в массив
$meta = array(); //Устанавливаем массив
$meta['title']=$array['title']; //Присваиваем метаданные
$meta['description'] = $array['description'];
$meta['author'] = $array['author'];
$meta['keywords'] = $array['keywords'];
return $meta; //Возвращаем массив метаданных
}
обнаружил в своем проекте 3 летней давности. сижу и тихо офигеваю)
+172
if(!empty($_SESSION["aktion"])){
//Если сесии не найдено то проверяем если куки
if(isset($_COOKIE["key"]) && isset($_COOKIE["PHPSESSID"]) && isset($_COOKIE["wrkesh"])){
//Прогоняем куки через фильтры
$test["key"] = htmlspecialchars($_COOKIE["key"]);
$test["key"] = stripslashes($_COOKIE["key"]);
$test["key"] = mysql_real_escape_string($_COOKIE["key"]);
$test["PHPSESSID"] = htmlspecialchars($_COOKIE["PHPSESSID"]);
$test["PHPSESSID"] = stripslashes($_COOKIE["PHPSESSID"]);
$test["PHPSESSID"] = mysql_real_escape_string($_COOKIE["PHPSESSID"]);
$test["wrkesh"] = htmlspecialchars($_COOKIE["wrkesh"]);
$test["wrkesh"] = stripslashes($_COOKIE["wrkesh"]);
$test["wrkesh"] = mysql_real_escape_string($_COOKIE["wrkesh"]);
//проверяем если такая запись в бд
$test_result = mysql_query("SELECT * FROM session WHERE md_5_id='$test[wrkesh]' AND ip='$_SERVER[REMOTE_ADDR]' AND clucc='$test[key]' AND sid='$test[PHPSESSID]'");
$test_myrow = mysql_fetch_array($test_result);
if($test_myrow ==true){
//Если даные с кук и бд совподают то создаём сессию
$_SESSION["aktive"] ="aktive";
mysql_close();
}
}
}
С "Ответов" mail.ru - типа проверка безопасности.
+94
function WindowProc(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM ): LRESULT; stdcall;
type
Item = record
szItemNr: array[0..8] of char;
szItem: array[0..32] of char;
szItemDescription: array[0..32] of char;
end;
var
ListColumn: LV_COLUMN;
ListItem: LV_ITEM;
begin
// In case of Msg ...
case Msg of
WM_CREATE: // Create?
begin
// Create list
ListView := CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, '', WS_VISIBLE Or WS_CHILD Or LVS_REPORT Or LVS_SHOWSELALWAYS,
10, 10, 524, 300, Wnd, 0, hInstance, nil);
ListView_SetExtendedListViewStyle(ListView, LVS_EX_FULLROWSELECT Or LVS_EX_GRIDLINES);
// Filling list columns
with ListColumn do begin
mask := LVCF_FMT Or LVCF_WIDTH Or LVCF_TEXT Or LVCF_SUBITEM;
fmt := LVCFMT_LEFT;
iSubItem := 0;
cx := 200;
pszText := 'File name';
ListView_InsertColumn(ListView, 0, ListColumn);
iSubItem := 1;
cx := 250;
pszText := 'Folder path';
ListView_InsertColumn(ListView, 1, ListColumn);
iSubItem := 2;
cx := 70;
pszText := 'File size';
ListView_InsertColumn(ListView, 2, ListColumn);
end;
with ListItem do begin
mask := LVIF_TEXT;
iItem := 1;
iSubItem := 1;
pszText := PChar('test');
cchTextMax := SizeOf(PChar('test')) + 1;
end;
ListView_InsertItem(ListView, ListItem);
ListView_SetItemText(ListView, 1, 1, PChar('Hello world!'));
// Create static text, progress bar and buttons
StaticText := CreateWindowEx(0, 'Static', '', WS_CHILD Or WS_VISIBLE Or SS_CENTER,
10, 310, 524, 16, Wnd, ID_StaticText, hInstance, 0);
ProgressBar := CreateWindowEx(0, PROGRESS_CLASS, nil, WS_CHILD Or WS_VISIBLE Or PBS_SMOOTH,
9, 326, 525, 17, Wnd, ID_ProgressBar, hInstance, nil);
Button_Start := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Start', BS_DEFPUSHBUTTON Or WS_VISIBLE Or WS_CHILD,
150, 350, 70, 25, Wnd, ID_Button_Start, hInstance, nil );
Button_Pause := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Pause', WS_VISIBLE Or WS_CHILD Or WS_DISABLED,
230, 350, 70, 25, Wnd, ID_Button_Pause, hInstance, nil );
Button_Stop := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Stop', WS_VISIBLE Or WS_CHILD Or WS_DISABLED,
310, 350, 70, 25, Wnd, ID_Button_Stop, hInstance, nil );
end;
WM_DESTROY: // Closing?
begin
PostQuitMessage(0);
Result := 0;
Exit; // Bye.
end;
WM_COMMAND: // Any command?
case LoWord(wParam) of
// ....................................
end;
end;
Пристрелите меня кто-нибудь. Или объясните, как работает этот волшебный listview %)
+67
package bytestring;
public class Main {
public static void main(String[] args) {
String source = new String("A ya sdelal etu hren s perevorotom stroki s ispolzovaniem bayta");
byte bytes[] = source.getBytes();
bytes = reverse(bytes);
String destination = new String(bytes);
System.out.println(destination);
}
private static void switchBytes(byte[] array, int a, int b) {
byte t = array[a];
array[a] = array[b];
array[b] = t;
}
public static byte[] reverse(byte[] bytes) {
int i, j;
int first, last;
int length = bytes.length;
//Переворачиваем всю строку
for(i = 0; i < length / 2; i++)
switchBytes(bytes, i, length - i - 1);
//Переворачиваем каждое слово строки
first = 0;
for(i = 1; i <= length; i++)
if(i == length || bytes[i] == ' ') {
last = i - 1;
for(j = first; j <= first + (last - first) / 2; j++)
switchBytes(bytes, j, first + last - j);
first = i + 1;
}
return bytes;
}
}
+147
int count(int a)
{
int cnt=0;
while(a)
{
++cnt;
}
return cnt;
}
Ф-ция для подсчета количества знаков числа. Взято с www.cyberforum.ru
+68
package bytestring;
public class Main {
public static void main(String[] args) {
String source = new String("A ya sdelal etu hren s perevorotom stroki s ispolzovaniem bayta");
byte bytes[] = source.getBytes();
////////////////////////////////////////////////////////////////////////
int i, j;
int length, first, last;
byte a;
length = bytes.length;
//Переворачиваем всю строку
for(i = 0; i < length / 2; i++) {
a = bytes[i];
bytes[i] = bytes[length - i - 1];
bytes[length - i - 1] = a;
}
//Переворачиваем каждое слово строки
first = 0;
for(i = 1; i <= length; i++)
if(i == length || bytes[i] == ' ') {
last = i - 1;
for(j = first; j <= first + (last - first) / 2; j++) {
a = bytes[j];
bytes[j] = bytes[first + last - j];
bytes[first + last - j] = a;
}
first = i + 1;
}
////////////////////////////////////////////////////////////////////////
char destination[] = new char[bytes.length];
for(i = 0; i < bytes.length; i++)
destination[i] = (char) bytes[i];
System.out.println(String.copyValueOf(destination));
}
}
+147
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#define N 5
#define TSK "durak"
using namespace std;
int m[N];
int main(void){
freopen(TSK".in", "rt", stdin);
freopen(TSK".out", "wt", stdout);
scanf("%d%d%d%d", &m[0], &m[1], &m[2], &m[3]);
sort(m, m + 4);
int ans(0);
for(int i = 1; i < 4; i++){
if(m[i] == m[i-1] && m[i] != 0)
ans++;
}
printf("%d\n", ans);
return 0;
}