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,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);
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
writeln('Trong day co ',dem,' phan tu co gia tri bang ',k);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,A[100];
cin>>n;
for (int i=1; i<=n; i++)
cin>>A[i];
for (int i=1; i<=n; i++)
cout<<A[i]<<" ";
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]>10 then inc(dem);
writeln('So phan tu lon hon 10 la: ',dem);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
writeln('So luong so chan la: ',dem1);
writeln('So luong so le la: ',dem2);
t:=0;
s:=1;
for i:=1 to n do
begin
if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];
if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];
end;
writeln('Tong cac so o vi tri chan co gia tri le la: ',t);
writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
writeln('Cac so chan va lon hon 10 la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]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;
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong mang do la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,j;
bool kt;
int main()
{
freopen("nguyento.inp","r",stdin);
freopen("nguyento.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]>1)
{
kt=true;
for (j=2; j*j<=a[i]; j++)
if (a[i]%j==0) kt=false;
if (kt==true) cout<<a[i]<<" ";
}
return 0;
}
uses crt;
var a:array[1..250]of integer;
i,n,dem,t,t1,t2,t3,t4:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=250);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until (0<a[i]) and (a[i]<=500);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2=1 then inc(dem);
writeln('So phan tu co gia tri le la: ',dem);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu co chi so chan la: ',t);
t1:=0;
for i:=1 to n do
if i mod 2=1 then t1:=t1+a[i];
writeln('Tong cac phan tu co chi so le la: ',t1);
t2:=0;
for i:=1 to n do
if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];
writeln('Tong cac phan tu chan co chi so chan la: ',t2);
t3:=0;
for i:=1 to n do
if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];
writeln('Tong cac phan tu co chi so le la: ',t3);
t4:=0;
for i:=1 to n do
t4:=t4+a[i];
writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);
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.
Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
edn;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
Bài 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 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0) dem++;
}
cout<<dem;
return 0;
}
Bài 2:
uses crt;
var a:array[1..199]of integer;
i,n:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------xuat-------------------------------}
for i:=1 to n do write(a[i]:4);
readln;
end.
Bài 3:
uses crt;
var a:array[1..199]of integer;
i,n,x,dem:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------xu-ly-------------------------------}
write('x='); readln(x);
dem:=0;
for i:=1 to n do
if a[i]=x then inc(dem);
writeln('trong day co ',dem,' gia tri ',x);
readln;
end.
Cảm ơn bn nha!