Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
program kitu;
uses crt;
var i,j,k:integer;
s1,s2:string;
begin
clrscr;
write('nhap xau:')readln(s1);
s2:='';
for i:=1 to length(s1) do
if (s1[i]>='1')and(s1[i]<='9')then s2:=s2+21[i];
for i = 1 to 4
k:=i;
for j:=i to length(s)+i-4 do
if s2[k]<s2[j] then k:=j;
if k>i then delete(s,i,k-i);
end;
writeln(copy(s,1,4));
readln;
end.
const fi='tong.inp';
fo='tong.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
end.
uses crt;
var a,b,c:array[1..1000]of integer;
i,n,dem,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
for i:=1 to n do
if max=a[i] then
begin
inc(dem);
b[dem]:=a[i];
c[dem]:=i;
end;
if dem=1 then writeln('So lon nhat la: ',b[dem],' vi tri la: ',c[dem])
else writeln('So lon nhat la: ',b[1],' vi tri la: ',c[1]);
readln;
end.
#include <fstream>
using namespace std;
int gia_tri_cuoi(int x)
{
if (x < 10) return x;
int tong = 0;
while (x > 0)
{
tong += x % 10;
x /= 10;
}
return gia_tri_cuoi(tong);
}
int main()
{
ifstream fin("LUCKY.INP");
ofstream fout("LUCKY.OUT");
int a[105];
int N;
fin >> N;
for (int i = 0; i<N; ++i) fin >> a[i];
int LUCKY[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i<N; ++i) ++LUCKY[gia_tri_cuoi(a[i])];
int max = -1;
int ketqua = 0;
for (int i = 0; i<10; ++i)
{
if (LUCKY[i] > max)
{
ketqua = i;
max = LUCKY[i];
}
}
fout << ketqua << endl;
return 0;
}
program hotrotinhoc;
const fi='LUCKY.INP';
fo='LUCKY.OUT';
var n,k,a,i,max,d: byte;
dem,m,m1: array[0..105] of integer;
f: text;
function tong(x: byte): integer;
var t,t1: integer;
begin
t:=0; t1:=0;
while x<>0 do
begin
t:=t+(x mod 10);
x:=x div 10;
end;
while t<>0 do
begin
t1:=t1+(t mod 10);
t:=t div 10;
end;
tong:=t1;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,n);
for i:=1 to n do
read(f,m[i]);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=1 to n do
begin
m1[i]:=tong(m[i]);
inc(dem[m1[i]]);
end;
max:=0;
for i:=1 to n do
if dem[i]<>0 then
if max<=dem[i] then max:=dem[i];
write(f,max);
close(f);
end;
begin
ip;
out;
end.