var
n, Num, i, j, t: integer;
Count: array[1..12] of integer;
Names: array[1..12] of integer;
begin
for i := 1 to 12 do
begin
Count[i] := 0;
Names[i] := i;
end;
ReadLn(N); { Считываем количество запросов}
for i := 1 to N do
begin
ReadLn(t); {считали очередной запрос}
Count[t] := Count[t] + 1;
end;
{Сортируем массивы Names и Count в порядке убывания значений массива Count}
for i := 12 downto 2 do
for j := 2 to i do
if Count[j - 1] < Count[j] then
begin
t := Count[j];
Count[j] := Count[j - 1];
Count[j - 1] := t;
t := Names[j];
Names[j] := Names[j - 1];
Names[j - 1] := t;
end;
for i := 12 downto 1 do
if Count[i] > 0 then
WriteLn(Names[i], ' ', Count[i]);
end.
Объяснение:
Delphi
Можно считать, но проще простой перестановкой символов.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm3 = class(TForm)
Edit1: TEdit;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure ReDo;
public
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
Memo1.Clear;
redo;
end;
procedure TForm3.ReDo;
var
s, s1, s2, s3 : string;
begin
s := edit1.Text;
s1 := s[1];
s2 := s[2];
s3 := s[3];
Memo1.Lines.Add(format('1-я цифра %s',[s1]));
Memo1.Lines.Add(format('2-я цифра %s',[s2]));
Memo1.Lines.Add(format('3-я цифра %s',[s3]));
Memo1.Lines.Add(format('Получилось число %s',[s3+s2+s1]));
end;
end.
<TR>...</TR>
Объяснение:
Рядки <TR>...</TR>
Клітинки таблиці <TD>...</TD>