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 HOC24;
var d,i,n,x: integer;
t: longint;
a: array[1..32000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Chi so cac phan tu co gia tri bang 0 la: ');
for i:=1 to n do if a[i]=0 then write(i,' ');
writeln;
d:=0; t:=0;
write('Nhap X: '); readln(x);
for i:=1 to n do if a[i]>x then d:=d+1;
writeln('Co ',d,' phan tu co gia tri lon hon ',x);
if n=20 then
begin
for i:=5 to 20 do t:=t+a[i];
end else write('Du lieu da cho chua du 20 phan tu');
write('Tong cac phan tu co gia tri nam trong doan 5 den 20 la: ',t);
readln
end.
uses crt;
var a:array[1..250]of integer;
i,n,t,x,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Chi so cac phan tu co gia tri bang 0 la: ');
for i:=1 to n do
if a[i]=0 then write(i:4);
writeln;
write('Nhap x='); readln(x);
dem:=0;
for i:=1 to n do
if a[i]>x then inc(dem);
writeln('So phan tu lon hon ',x,' la: ',dem);
t:=0;
for i:=1 to n do
if (5<=a[i]) and (a[i]<=20) then t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int A[500],n,i,dem,dem1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=n; i>=1; i--) cout<<A[i]<<" ";
cout<<endl;
dem=0;
for (int i=1; i<=n; i++)
if (A[i]<10) dem++;
cout<<dem<<endl;
dem1=0;
for (int i=1; i<=n; i++)
if (A[i]>1)
{
bool kt=true;
for (int j=2; j*j<=A[i]; j++)
if (A[i]%j==0) kt=false;
if (kt==true) dem1++;
}
cout<<dem1;
return 0;
}
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
Bai 2:
uses crt;
var a:array[1..100]of integer;
i,n,t,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
nn:=a[1];
for i:=1 to n do
if nn>a[i] then nn:=a[i];
write(nn);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[10],i;
int main()
{
for (i=1; i<=10; i++)
cin>>a[i];
for (i=1; i<=10; i++)
cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=10; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
uses crt;
var A : array [1 .. 10] of integer;
i : integer;
begin
clrscr;
for i := 1 to 10 do
begin
write('Nhap so thu ', i ,' : ');
readln(A[i]);
end;
write('Cac gia tri chan : ');
for i := 1 to 10 do
if A[i] mod 2 = 0 then
write(A[i], ' ');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long a[40],i,n,ln;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
for (i=n; i>=1; i--)
if (ln==a[i])
{
cout<<i;
break;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,t,t1,dem,dem1;
//chuongtrinhcon
bool ktnt(long long x)
{
if (x<=1) return(false);
for (int i=2; i*i<=x; i++)
if (x%i==0) return(false);
return true;
}
//chuongtrinhchinh
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];
cout<<t<<endl;
dem=0;
for (i=1; i<=n; i++) if (a[i]%3==0) dem++;
cout<<dem<<" ";
t1=0;
dem1=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
t1+=a[i];
dem1++;
}
cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;
for (i=1; i<=n; i++)
if (ktnt(a[i])==true) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[6],i,t,t1;
int main()
{
t=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
if (a[i]%2==0) t=t+a[i];
}
t1=0;
for (i=1; i<=n; i++)
if ((a[i]%2!=0) and (i%2==0)) t1=t1+a[i];
cout<<t<<endl;
cout<<t1;
return 0;
}