int mul(int * arr, int N, int shift = 0)
{
switch (N)
{
case 1:
return arr[shift];
break;
case 2:
return (arr[shift] * arr[shift + 1]);
break;
default:
int M = N / 2;
return (mul(arr, M, shift) * mul(arr, N - M, shift + M));
}
}
type tabelo = array[byte,byte] of integer;
procedure filling_spiral(var Q:tabelo; a,b:integer);
var c,d,e,f,g,h:integer;
begin
c:=a-1;
d:=b-1;
e:=1;
if a>=b then f:=b else f:=a;
for g:=0 to (f div 2) do
begin
for h:=b-d+g to d-g do
begin
if Q[a-c+g,h]=0 then Q[a-c+g,h]:=e else break;
inc(e)
end;
for h:=a-c+g to c-g do
begin
if Q[h,b-g]=0 then Q[h,b-g]:=e else break;
inc(e)
end;
for h:=b-g downto b-d+g+1 do
begin
if Q[a-g,h]=0 then Q[a-g,h]:=e else break;
inc(e)
end;
for h:=a-g downto a-c+g do
begin
if Q[h,b-d+g]=0 then Q[h,b-d+g]:=e else break;
inc(e)
end
end
end;
auto max = arr[0];
for (int i = 0; i < N; ++i)
if (max < arr[i]) max = arr[i];
auto max = arr[0]
for (auto i : arr)
if (max < i) max = i;
vector
или через квадратные скобки. class BaseMatrix
{
private:
int M, N;
int * matrix;
public:
BaseMatrix(int m, int n);
~BaseMatrix();
void SetItem(int m, int n, int x);
int GetItem(int m, int n);
}
class Matrix
{
private:
BaseMatrix * matrix;
public:
Matrix(int m, int n);
~Matrix();
void UserSet();
void AddRow();
void DelRow();
}
// В конструкторе класса level
cruiser cruiser(SDL_Surface *screen);
// В конце функции main
level level(screen);
cruiser cruiser_obj = cruiser(SDL_Surface *screen);
level level_obj = level(screen);
// Или проще:
cruiser cruiser_obj(SDL_Surface *screen);
level level_obj(screen);
cruiser(SDL_Surface *screen);
level(screen);