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.
uses crt;
var n,i,d,max,x,y:integer;
st:string;
begin
clrscr;
write('Nhap n='); readln(n);
str(n,st);
d:=length(st);
max:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if max<x then max:=x;
end;
writeln(max);
readln;
end.
Program HOC24;
var i: byte;
s: string;
begin
readln(s);
for i:=1 to length(s) do
begin
if s[i]='1' then write('mot ');
if s[i]='2' then write('hai ');
if s[i]='3' then write('ba ');
if s[i]='4' then write('bon ');
if s[i]='5' then write('nam ');
if s[i]='6' then write('sau ');
if s[i]='7' then write('bay ');
if s[i]='8' then write('tam ');
if s[i]='9' then write('chin ');
if s[i]='0' then write('khong ');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n%2==0) cout<<"Chan";
else cout<<"Le";
return 0;
}
var A:
array[1..n] of int64;
i, n, count: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
count := 0;
for i := 1 to n do
if A[i] > 0 then
count := count + 1;
writeln('So luong cac so nguyen duong trong mang la: ', count); end.
Var a,b:real;
Begin
Write('a = ');readln(a);
Write('b = ');readln(b);
If a > b then write('So lon la ',a:10:2)
Else if b > a then write('So lon la ',b:10:2)
Else write('Hai so bang nhau');
Readln;
End.
Bài 1:
uses crt;
var n,i,dem,maxd,vt,vt1,vt2,vt3,maxa,dem1:integer;
a,b,c,d,e,f,g:array[1..100]of integer;
mind,mina:int64;
begin
clrscr;
repeat
write('n='); readln(n);
if (n<=0) or (n>100) then writeln('nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------so-hang-duong-----------------------}
dem:=0;
for i:=1 to n do
if a[i]>0 then
begin
inc(dem);
b[dem]:=a[i];
end;
maxd:=0;
for i:=1 to dem do
if maxd<b[i] then maxd:=b[i];
vt:=0;
for i:=1 to n do
if maxd=a[i] then
begin
vt:=vt+1;
c[vt]:=i;
end;
writeln('so hang duong lon nhat cua day la: ',maxd);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt do
write(c[i]:4);
writeln;
mind:=maxint;
for i:=1 to dem do
if mind>b[i] then mind:=b[i];
vt1:=0;
for i:=1 to n do
if mind=a[i] then
begin
inc(vt1);
d[vt1]:=i;
end;
writeln('so hang duong nho nhat cua day la: ',mind);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt1 do
write(d[i]:4);
{------------------------so-hang-am--------------------------}
writeln;
dem1:=0;
for i:=1 to n do
if a[i]<0 then
begin
inc(dem1);
e[dem1]:=a[i];
end;
maxa:=e[1];
for i:=1 to dem1 do
if maxa<e[i] then maxa:=e[i];
vt2:=0;
for i:=1 to n do
if maxa=a[i] then
begin
inc(vt2);
f[vt2]:=i;
end;
writeln('so hang am lon nhat cua day la: ',maxa);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt2 do
write(f[i]:4);
writeln;
mina:=maxint;
for i:=1 to dem1 do
if mina>e[i] then mina:=e[i];
vt3:=0;
for i:=1 to n do
if mina=a[i] then
begin
inc(vt3);
g[vt3]:=i;
end;
writeln('so hang am nho nhat cua day la: ',mina);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt3 do
write(g[i]:4);
readln;
end.
Bài 2:
uses crt;
var a,vt:array[1..10]of integer;
i,x,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap x='); readln(x);
dem:=0;
for i:=1 to 10 do
if a[i]=x then
begin
inc(dem);
vt[dem]:=i;
end;
if dem=0 then writeln('khong co gia tri ',x,' trong day')
else
begin
writeln('vi tri cua ',x,' trong day lan luot la:');
for i:=1 to dem do
write(vt[i]:4);
end;
readln;
end.
Bài 3:
uses crt;
var a:array[1..100,1..100]of integer;
n,i,j,t:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
for j:=1 to n do
begin
write('a[',i,',',j,']='); readln(a[i,j]);
end;
{----------------------------xuat-----------------------------}
writeln('ma tran ban vua nhap la:');
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:4);
writeln;
end;
{------------------tong-cac-phan-tu-tren-duong-cheo-chinh------------------}
t:=0;
for i:=1 to n do
for j:=1 to n do
if i=j then t:=t+a[i,j];
writeln('tong cac phan tu tren duong cheo chinh la: ',t);
readln;
end.