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.
![](https://rs.olm.vn/images/avt/0.png?1311)
![](https://rs.olm.vn/images/avt/0.png?1311)
a)
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
b)
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Bài 1
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so chan la ',s);
Readln
End.
Bài 2
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so le la ',s);
Readln
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
1.
Program Tim_Max;
Var A:Array[1..255] of Integer;
i, n, Max: Integer;
Begin
Write('Nhap n: '); Readln(n);
For i := 1 to n do
Begin
Write('Nhap phan tu A[',i,'] = '); Readln(A[i]);
End;
Max := A[1];
For i := 2 to n do if A[i]>Max then Max := A[i];
Write('Phan tu lon nhat la :',Max);
Readln
End.
2.
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,j,Tam:Integer;
Begin
{Nhập mảng}
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
{Sắp xếp}
For i:=1 To N-1 Do
For j:=i+1 To N Do
If A[i]>A[j] Then
Begin
Tam:=A[i]; A[i]:=A[j]; A[j]:=Tam;
End;
{In kết quả ra màn hình}
Writeln('Ket qua sau khi sap xep:');
For i:=1 To N Do Write(A[i]:5);
Readln;
End.
3.
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,x:Integer;
Function TimKiem(x, N: Integer; A:Mang):Integer;
Var i:Integer;
Begin
I:=1;
While (I <= N) and (X<>A[I]) do I:=I+1; {{{{tại sao lại phải làm như bước này, tại sao lại lấy i đi so sánh với N}}}}
If I <= N Then Timkiem:=I Else Timkiem:=0;
End;
Begin
{Nhập mảng}
Write(‘Nhap N=’); Readln(N);
For i:=1 To N Do
Begin
Write(‘A[‘,i,’]=’); Readln(A[i]);
End;
Write(‘Nhap X=’); Readln(x);
{Kết quả tìm kiếm}
If TimKiem(X,N,A)<>0 Then
Writeln(‘Vi tri cua X trong mang la:’, TimKiem(X,N,A))
Else Writeln(‘X khong co trong mang.’);
Readln;
End.
câu 1 tham khảo cái này nhé
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,Max:Integer;
Begin
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
Max:=A[1];
For i:=2 To N Do
If Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
Readln;
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var a:array[1..100]of integer;
i,n,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i] mod k=0 then write(a[i]:4);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=1000);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until abs(a[i])<=1000;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]=0 then inc(dem);
writeln('So phan tu bang 0 la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu chan la: ',t);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Xét tổng vô hạn:
Sn=0,2+0,07+0,007+0,0007+...Sn=0,2+0,07+0,007+0,0007+...
Sn=15+7100+71000+710000+...Sn=15+7100+71000+710000+...
Sn=15+7100(1+110+1102+...)Sn=15+7100(1+110+1102+...)
Sn=15+7100.11−110=518Sn=15+7100.11−110=518
Vậy 0,277777...=518
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (a[i]>0)
{
dem++;
t=t+sqrt(a[i]);
}
cout<<t;
return 0;
}
Program bai1;
uses crt;
var a: array [1. .1000] of integer;
i,n,dem: integer;
begin clrscr;
write('nhap n = ');
readln(n);
for i:= 1 to n do begin write('nhap a[',i,'] = ');
readln(a[i]);
end;
dem:= 0;
for i:= 1 to n do if a[i] < 0 then dem:= dem+1; write('so luong cac so am la : ',dem);
readln;
end.