#include <iostream> using namespace std; int A[20];
int main() { int n, c, p, max; int counter, ncounter; counter = 0; cin >> n; c = n; p = n; for (c; c>0;) { counter++; c = c / 10; A[counter] = p - c * 10; p = c; if (c > 0 && c < 10) { A[counter + 1] = c; } } max = 0; ncounter = 0; for (int s = 1; s <= counter; s++) { if (A[s] > max) { max = A[s]; ncounter = 0; } if (A[s] == max) { ncounter++; } } cout << ncounter; system("pause"); return 0; }
using namespace std;
int A[20];
int main()
{
int n, c, p, max;
int counter, ncounter;
counter = 0;
cin >> n;
c = n;
p = n;
for (c; c>0;)
{
counter++;
c = c / 10;
A[counter] = p - c * 10;
p = c;
if (c > 0 && c < 10)
{
A[counter + 1] = c;
}
}
max = 0;
ncounter = 0;
for (int s = 1; s <= counter; s++)
{
if (A[s] > max)
{
max = A[s];
ncounter = 0;
}
if (A[s] == max)
{
ncounter++;
}
}
cout << ncounter;
system("pause");
return 0;
}
4:
var a: array [1..3] of integer;
i,min,max : integer;
begin
for i:= 1 to 3 do
begin
write('a[',i,'] = ');
read(a[i]);
writeln;
end;
min:= a[1];
max:= a[1];
for i:= 1 to 3 do
begin
if a[i] < min then
begin
min:= a[i];
end;
end;
for i:= 1 to 3 do
begin
if a[i] > max then
begin
max:= a[i];
end;
end;
writeln('min = ',min);
writeln('max = ',max);
end.
5:
var a: array [1..5] of integer;
i,max : integer;
begin
for i:= 1 to 5 do
begin
write('a[',i,'] = ');
read(a[i]);
writeln;
end;
max:= a[1];
for i:= 1 to 3 do
begin
if a[i] > max then
begin
max:= a[i];
end;
end;
writeln('max = ',max);
end.