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..200]of integer;
n,i,k,t,t1: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);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if a[i] mod k=0 then t1:=t1+a[i];
writeln('Tong cac phan tu le la: ',t);
writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x<0) t+=x;
}
cout<<t;
return 0;
}
#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 a:array[1..100]of integer;
n,i,k,dem,dem1: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;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
Câu 1:
var a:array[1..100]of integer;
Câu 2:
uses crt;
var a:array[1..10]of integer;
i:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 10 do
write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..15]of integer;
i,n,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=15);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=100;
end;
writeln('Mang da nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 3 la: ',t);
writeln('Cac so chan o vi tri le trong day la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);
readln;
end.
Program HOC24;
var m,i,d: integer;
a: array[1..32000] of integer;
begin
write('Nhap m= '); readln(m);
for i:=1 to m do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap X = '); readln(x);
d:=0;
for i:=1 to n do if a[i]=x then d:=d+1;
write(X,' xuat hien ',d,' lan trong mang');
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.
cau 1:
uses crt;
var a:array[1..100] of integer;
n,i,min: integer;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
for i:=2 to n do
if min>a[i] then min=a[i];
writeln(a[i]);
readln;
end.
cau 2:
uses crt;
g:text;
s:string;
const fo='CHUSO.TXT';
begin
assign(g,fo);
rewrite(g);
readln(s);
for i:=1 to length(s) do
if not((s[i] in ['a'..'z'])and(s[i] in ['A'..'Z])) then delete(s,i,1);
writeln(g,s);
end.
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.
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[10000];
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
1:
uses crt;
var k:array[1..50]of real;
a,i,dem:integer;
begin
clrscr;
write('a='); readln(a);
for i:=1 to a do
begin
write('k[',i,']='); readln(k[i]);
end;
{-------------------xu-ly-------------------------}
writeln('cac so khong am trong day la: ');
for i:=1 to a do
if k[i]>=0 then write(k[i]:4);
writeln;
dem:=0;
for i:=1 to a do
if k[i]<0 then inc(dem);
writeln('so so am trong day la: ',dem);
readln;
end.
2:
uses crt;
var b:array[1..30]of integer;
m,i:integer;
s:int32;
begin
clrscr;
write('nhap m='); readln(m);
for i:=1 to m do
begin
write('b[',i,']='); readln(b[i]);
end;
{--------------------------------xu-ly-------------------------}
s:=1;
for i:=1 to m do
if b[i] mod 3=0 then s:=s*b[i];
writeln('tich cac so nguyen la boi cua 3 la: ',s);
writeln('cac so khong la boi cua 3 trong day la: ');
for i:=1 to m do
if b[i] mod 3<>0 then write(b[i]:4);
readln;
end.
Cảm ơn nhiều nhaa