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 a:array[1..100]of integer;
i,n,dem,max,t,min,dem1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=-32000;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem:=dem+1;
if max<a[i] then max:=a[i];
end;
if dem=0 then writeln('Trong day khong co so chan')
else begin
writeln('So so chan la: ',dem);
writeln('So chan lon nhat la: ',max);
end;
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+a[i];
writeln('Tong cac so o vi tri le la: ',t);
min:=maxint;
dem1:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
inc(dem1);
if min>a[i] then min:=a[i];
end;
if dem1=0 then writeln('Trong day khong co so le')
else writeln('So le nho nhat la: ',min);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
uses crt;
var a:array[1..5]of integer;
max,i:integer;
begin
clrscr;
for i:=1 to 5 do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to 5 do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
Câu 2:
uses crt;
var a:array[1..6]of integer;
min,i:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to 6 do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
bạn tham khảo
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int n,x,i,cnt,res;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
cin>>x;
if(x%cnt==0) res++;
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int gh=1000;
int n,x,i,cnt,res,dem[gh];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
cin>>x;
if(x%cnt==0) { res++; dem[res]=x;}
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
cout<<"\n"<<"cac phan tu do la: "<<"\n";
for(i=1;i<=res;i++)
cout<<dem[i]<<" ";
return 0;
}
// đây mới đúng mik đọc lỗi đề nha bạn!!
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 10=0 then
begin
write(a[i]:4);
inc(dem);
t:=t+a[i];
end;
writeln;
writeln(dem);
writeln(t);
readln;
end.
Program HOC24;
var a: array[1..1000] of integer;
i,n,max: integer;
begin
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
t:=a[1];
for i:=2 to n do if a[i]>max then max:=a[i];
writeln('So lon nhat trong mang la: ',max);
write('Vi tri cua cac phan tu do la: ');
for i:=1 to n do if a[i]=max then write(i,' );
readln
end.
Uses crt;
Var a:array[1..6] of integer;
I,s:integer;
Begin
Clrscr;
For i:=1 to 6 do
Begin
Write('a[',i,']='); readln(a[i]);
End;
S:=1;
For i:=1 to 6 do
If a[i] mod 3=0 then s:=s*a[i];
Writeln(s);
Readln;
End.