-
var n,max:longint;
beginmax:=-maxlongint;
for i:=1 to n do
if n>max then max:=n;
writeln(max);
end.This is the most basic way.
-
program p1;
type node=record This is a record type, number is the ordinal number, and data is the data.
number:integer;
data:integer;
end;var a:array[1..1000] of node;
i,j,n:integer;
procedure qsort(h,t:integer);This is the quicksort section.
var i,j,x,y:integer;
begini:=h;
j:=t;x:=a[(i+j) mod 2].data;
while i<=j do
beginwhile a[i].datax do dec(j);
if ih+1 then qsort(h,t-1);
end;begin main program.
fillchar(a,sizeof(a),0);
readln(n);
for i:=1 to n do
beginread(a[i].data);
a[i].number:=i;
end;write(a[n].number,' ');
for i:=n-1 downto 1 do
if a[i].data<>a[n].data then break
else write(a[i].number,' ');
end.Idea: Add an ordinal number field when entering data, sort the data while also bringing the ordinal number, because it is arranged in ascending order, so it is necessary to start from the end of the array, scan from back to front, and output the serial number when encountering the same as the maximum data, and jump out when you encounter the first different one, similar to the pruning idea of search. The knowledge used here is quicksorting, and record-based data (arrays, you will).
I wish you OI success!
-
program maxs;
varn,i,max:longint;
a:array[1..1000] of longint;You can decide how big the array is.
beginreadln(n);
for i:=1 to n do
beginread(a[i]);
if a[i]>max then max:=a[i];
end;Read in and find out the maximum.
for i:=1 to n do
if a[i]=max then write(i,' ');Scan it with a for loop and output if a[i] is the maximum.
writeln;
end.
-
It's very easy, find the maximum value and then find the output i if the ith value is the maximum value
-
vari,n,m,max,min:longint;
beginreadln(n);
max:=-maxlongint;
min:=maxlonint;Initialize.
for i:=1 to n do
beginreadln(m);Enter a number, cycle n times if m>max then max:=m;
if mwriteln(max) maximum;
writeln(min);Least.
-
vari,n,max,min:integer;
a:array[1..100]of integer;
beginreadln(n);Enter n
max:=-maxint+1;Initialize.
min:=maxint;Initialize.
for i:=1 to n do
beginread(a[i]);Read in each number.
if a[i]>max then max:=a[i];If the number is greater than max, a value is assigned to max
if a[i]end;
writeln(max,' ',min);output end
-
First, let's talk about random functions.
random generates a random number between 0 and 1 (1 will not be taken to).
random(x) followed by the parameter x (integer) means that a random number between 0 x is generated (x will not be taken).
Randomize random function toggle, which is put first every time you set a random number.
const maxnum=100;where maxnum represents the size of the number you want to generate randomly, see above.
var i,max,min,sum:integer;where i is a cyclic variable, max is the maximum, min is the minimum, and sum is the sum.
a:array[1..10]of integer;An array of 10 cells for storing value.
beginrandomize;Turn on the random switch.
for i:=1 to 10 do begin a[i]:=random(maxnum); sum:=sum+a[i];end;
Let the 10 cells in the array be assigned as random numbers, and s will be used for summing.
for i:=1 to 10 do write(a[i],'Output-by-output.
writeln;
writeln(sum/10:0:2);Calculate the average and output (keep two decimal places).
max:=-maxint;min:=maxint;The maxint initialization maxint of 32767 is a constant preset by the pascal.
for i:=1 to 10 do begin Iterate through the array to find the maximum and minimum values.
if a[i]>max then max:=a[i];
if a[i]end;writeln(max,' min);Output Maximum Minimum value.
end.If there's anything else you don't know how to ask.
-
program exam;
var n,i,max:longint;
a:array[1..100000] of longint;
beginwhile not eof do
beginreadln(n);
max:=0-maxlongint;
for i:=1 to n do beginread(a[i]);
if a[i]>max then max:=a[i];
end;readln;
writeln(max);
end;end.
Simple fighting.
The data range is within the range of all the numbers longint, and if n is less than 100,000, it is not enough to change it yourself.
-
varl,i,j,t:longint;
a:array[1..1000]of longint;
beginwhile not eoln do
begininc(l);
read(a[l]);
end;for i:=1 to l-1 do
for j:=i+1 to l do
if a[i]writeln(l,' ',a[1]);
end.Simple.
No n needs to be entered
Enter the var
l,i,j,t,n:longint;
a:array[1..1000]of longint;
beginreadln(n);
while not eoln do
begininc(l);
read(a[l]);
end;for i:=1 to l-1 do
for j:=i+1 to l do
if a[i]writeln(l,' ',a[1]);
end.
varn,m,i:integer;
t:int64; >>>More
Just use an array.
var a:array[1..1000]of longint; >>>More
varn,i,j:integer;
beginreadln(n); >>>More
Is the audio volume turned up?
**Talent double** specialization Point out the axe and hammer specialization The main hand holds the high tide of BT No. 1 The deputy hand holds the swift steel hammer dropped by the mob Specifically, go to Warcraft Warrior to find the relevant post. >>>More