- 1
enum { SIZEOF_INT_AS_STR = sizeof("4294967295,")-1 };Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+98
enum { SIZEOF_INT_AS_STR = sizeof("4294967295,")-1 };Что это? :-O
+98
if RadioGroup1.ItemIndex=0   then cpr:=cpr+1;
if RadioGroup1.ItemIndex=1   then cth:=cth+1;
if RadioGroup2.ItemIndex=0   then cch:=cch+1;
if RadioGroup2.ItemIndex=1  then czs:=czs+1;
if RadioGroup3.ItemIndex=0   then chd:=chd+1;
if RadioGroup3.ItemIndex=1  then cpr:=cpr+1;
if RadioGroup4.ItemIndex=0   then  cth:=cth+1;
if RadioGroup4.ItemIndex=1  then cch:=cch+1;
if RadioGroup5.ItemIndex=0   then czs:=czs+1;
if RadioGroup5.ItemIndex=1  then chd:=chd+1;
if RadioGroup6.ItemIndex=0   then cpr:=cpr+1;
if RadioGroup6.ItemIndex=1  then cch:=cch+1;
if RadioGroup7.ItemIndex=0   then chd:=chd+1;
if RadioGroup7.ItemIndex=1  then cth:=cth+1;
....// Это всё в 60 строк
if (cpr>cth) and (cpr>cch) and (cpr>czs) and (cpr>chd) then cpr1:=+1
else
if (cth>cpr) and (cth>cch) and (cth>czs) and (cth>chd) then cth1:=+1
else
if (cch>cpr) and (cch>cth) and (cch>czs) and (cch>chd) then cch1:=+1
else
if (czs>cpr) and (czs>cch) and (czs>cth) and (czs>chd) then czs1:=+1
else
if (chd>cpr) and (chd>cch) and (chd>czs) and (chd>cth) then chd1:=+1;
if cpr>chd or czs or cth or cch     then
begin
ShowMessage('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;')   ;
Datamodule4.ADOTable1.Edit;
Datamodule4.ADOTable1.FieldValues['test2']:=('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;');
Datamodule4.ADOTable1.Post;
end
else
if chd>cpr or cth or cch or czs   then   begin
ShowMessage('человек-техника – все технические профессии;')   ;
Datamodule4.ADOTable1.Edit;
Datamodule4.ADOTable1.FieldValues['test2']:=('человек-техника – все технические профессии;');
Datamodule4.ADOTable1.Post;
...... И далее результаты в общем их 5
отдельная кнопка для вывода остальных 10 вопросов х)
procedure TForm1.Button1Click(Sender: TObject);
begin
Radiogroup11.Visible:=true;
Radiogroup12.Visible:=true;
Radiogroup13.Visible:=true;
Radiogroup14.Visible:=true;
Radiogroup15.Visible:=true;
Radiogroup16.Visible:=true;
Radiogroup17.Visible:=true;
Radiogroup18.Visible:=true;
Radiogroup19.Visible:=true;
Radiogroup20.Visible:=true;
Button2.Visible:=True;
end;
            Программа тестирования на профориентацию 
хД сколько он radiogroup создал)
        
+98
for j:=k+1 to n+1 do
	begin
	r:=a[j,k]/a[k,k];
	for i:=k to n do
                begin
                a[j,i]:=power(((a[j,i]-r*a[k,i]):a[i,j]),a[j,i]);
                end;
            К сожалению, я уже забыл, какой идентификатор что значит :(
Придется переписывать.
        
+98
case ColorChunkStart of  
   0 : result := RGB(255,   
                     (255 div ColorChunk) * ColorChunkIndex,   
                     0);   
   1 : result := RGB(255 - (255 div ColorChunk) * ColorChunkIndex,   
                     255,   
                     0);   
   2 : result := RGB(0, 255, (255 div ColorChunk) * ColorChunkIndex);   
   3 : result := RGB(0,   
                     255 - (255 div ColorChunk) * ColorChunkIndex,   
                     255);   
   4 : result := RGB((255 div ColorChunk) * ColorChunkIndex,   
                     0,   
                     255);   
   5 : result := RGB(255,   
                     0,   
                     255 - (255 div ColorChunk) * ColorChunkIndex);   
  else  
    if WrapToRed <> false then  
      result := RGB(255, 0, 0) else  
      result := RGB(255, 0, 255);   
end;{Case}Говно?
+98
function Prime (N: longword): boolean;
var
	i : longword;
	Max : single;
begin
	if N = 2
		then Prime := true
	else if (N <= 1) or (N mod 2 = 0)
		then Prime := false
	else begin
		Prime := true;
		i := 3; Max := sqrt(N);
		while i <= Max do begin
			if N mod i = 0 then begin
				Prime := false; 
				exit
			end;
			i := i + 2
		end
	end
end;
var
	a, i : longword;
begin
	read(a);
	for i := 2 to a do
		if Prime(i)
			then writeln(i, ' is a prime number');
end.Нахождение простых чисел.
+98
Procedure TreeNodeBuilding(Tree: TTreeView; Query: TZQuery; DestinationNode: TTreeNode;
                          IdColumn, NameColumn, FilterColumn, TableType: String; Filtering:Boolean; ImageIndex:Integer);
  //-------------------------------------------------//
  Function AddOrNot:Boolean; //Фильтрация по ИД
  var
    Add: Boolean;
  begin
  Add:=False;
  If Filtering=False then Add:=True else
    begin
    if DestinationNode=nil then Add:=True else
      begin
      MyNodeParamPtr:=DestinationNode.Data;
      if MyNodeParamPtr^.id=Query.FieldValues[FilterColumn] then Add:=True;
      end;
    end;
  Result:=Add;
  end;
  //-------------------------------------------------//
  Procedure AddTreeNodeToViewer; //Добавление ветки
  var
    MyNode: TTreeNode;
  begin
  //Добавляем новую запись в массив и заполняем её
//  Inc(ArrMyNodeParamLength);
//  SetLength(ArrMyNodeParam, ArrMyNodeParamLength);
  New(MyNodeParamPtr);
  MyNodeParamPtr^.id:=Query.FieldValues[IdColumn];
  MyNodeParamPtr^.table:=TableType;
  //Добавляем новый узел дерева и указатель на соотв запись
  if DestinationNode=nil then
  MyNode:=Tree.Items.AddObject(DestinationNode, VarToStr(Query.FieldValues[NameColumn]), MyNodeParamPtr)
    else MyNode:=Tree.Items.AddChildObject(DestinationNode, VarToStr(Query.FieldValues[NameColumn]), MyNodeParamPtr);
  MyNode.ImageIndex:=ImageIndex;
  MyNode.SelectedIndex:=ImageIndex;
  end;
  //-------------------------------------------------//
begin
//
Query.First;
if AddOrNot=True then AddTreeNodeToViewer;
Query.Next;
while not Query.Eof do
  begin
  if AddOrNot=True then AddTreeNodeToViewer;
  Query.Next;
  end;
end;Добавление ветки в TreeView. Я тут явно перемудрил
+98
if a[512] < x then L := n – 512 + 1;
if a[L + 256] < x then L := L + 256;
if a[L + 128] < x then L := L + 128;
if a[L + 64] < x then L := L + 64;
if a[L + 32] < x then L := L + 32;
if a[L + 16] < x then L := L + 16;
if a[L + 8] < x then L := L + 8;
if a[L + 4] < x then L := L + 4;
if a[L + 2] < x then L := L + 2;
if a[L + 1] < x then L := L + 1;Взято из методического пособия по программированию - отрывок из алгоритма бинарного поиска (реализация для сходимости в 9 шагов)
+98
//
// Замена блоков __try/__finally нашей реализацией. Примеры использования:
// NTSTATUS SomeFunc() {
//     X *p = NULL;
//     NTSTATUS status = STATUS_SUCCESS;
//     Try {
//         p = new(NonPagedPool) X;
//         if (!p) Leave(status = STATUS_INSUFFICIENT_RESOURCES);
//
//         status = SomeKernelFunc();
//         LeaveNS(status = STATUS_UNSUCCESSFUL);
//     } Finally {
//         if (p) delete p;
//     }
//     return status;
// }
//
#define Try if (1)
#define Finally try_exit: NOTHING
#define Leave(s) { s; goto try_exit; }
#define LeaveNS(s) {if (!NT_SUCCESS(status)) Leave(s);}
#define Run(s) {status = s; LeaveNS(;);}Суровые исключения для Win32 драйвера
+98
procedure TfmAllParams.NInsertParamSelebrationClick(Sender: TObject);
var
  str: string;
begin
  str := //Новый год
    ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '01.01.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
    ' values(1,1,null,null,null) ' +
        //День св. Валентина
  ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '14.02.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
    ' values(14,2,null,null,null) ' +
        //8 марта
  ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '08.03.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
    ' values(8,3,' + #39 + 'жін.' + #39 + ',null,null) ' +
        //1 мая
  ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '01.05.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
    ' values(1,5,null,null,null) ' +
        //Пасха
  ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '04.04.2010' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
    ' values(4,4,' + #39 + 'Pasha' + #39 + ',2010) ' +
  ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '24.04.2011' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
    ' values(24,4,' + #39 + 'Pasha' + #39 + ',2011) ' +
   // И 10 таких же запросов на каждый год!
  ' if not exists (select id from sta_param_selebration ' +
    '            where date_selebration=' + #39 + '24.04.2022' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
    ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
    ' values(24,4,' + #39 + 'Pasha' + #39 + ',2022) ' +
+98
function TForm1.genpa(l: integer): string;
const cifr_i_english: string =
'ABCDEFGHIJKLMabcdefghijklm' +
'0123456789' +
'NOPQRSTUVWXYZnopqrstuvwxyz';
const cifr: string =
'1234567890';
const rus:string =
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
const cifr_i_rus: string =
'1234567890'+
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
const eng_i_rus: string =
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'+
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm';
const english: string =
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm';
const en_ru_cifr :string =
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm'+
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'+
'1234567890';
const spec :string =
'!@#$%^&*()"№;:?/,\|=+-_}{][';
const spec_ru :string =
'!@#$%^&*()"№;:?/,\|=+-_}{]['+
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
const eng_spec :string =
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm'+
'!@#$%^&*()"№;:?/,\|=+-_}{][';
const eng_ru_spec :string =
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm'+
'!@#$%^&*()"№;:?/,\|=+-_}{]['+
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
const cifr_spec :string =
'1234567890'+
'!@#$%^&*()"№;:?/,\|=+-_}{][';
const cifr_en_spec :string =
'1234567890'+
'!@#$%^&*()"№;:?/,\|=+-_}{]['+
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm';
const cifr_ru_en_spec :string =
'1234567890'+
'!@#$%^&*()"№;:?/,\|=+-_}{]['+
'NOPQRSTUVWXYZnopqrstuvwxyz'+
'ABCDEFGHIJKLMabcdefghijklm'+
'йцукенгшщзхъфывапролджэячсмитьбю'+
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ';
var
x,y,engh:integer;
str:string;
d:integer;
begin
   if CheckBox1.Checked =true then
   begin
   if CheckBox2.Checked =true then
   begin
   for d:=0 to l - 1  do
   begin
   engh:=Length(cifr_i_english);
   x:=RandomRange(1,engh);
   str:=str+cifr_i_english[x];
   end;
   result:=str;
   end;
   end;
   if CheckBox1.Checked =true then
   begin
   if CheckBox3.Checked =true then
   begin
   for d:=0 to l - 1  do
   begin
   engh:=Length(cifr_i_rus);
   x:=RandomRange(1,engh);
   str:=str+cifr_i_rus[x];
   end;
   result:=str;
   end;
   end;
   if CheckBox1.Checked =true then
   begin
   if CheckBox5.Checked =true then
   begin
   for d:=0 to l - 1  do
   begin
   engh:=Length(cifr_spec);
   x:=RandomRange(1,engh);
   str:=str+cifr_spec[x];
   end;МЯдаль мне ! Это говнокод говнокодов ! Супер генератор паролей !