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.
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.
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;
long long x,n,i,dem1,dem2,t1,t2;
int main()
{
cin>>n;
dem1=0;
dem2=0;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0)
{
dem1++;
t1+=x;
}
if (x<0)
{
dem2++;
t2+=x;
}
}
cout<<dem1<<" "<<dem2<<endl;
cout<<t1<<" "<<t2;
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.
#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;
}
uses crt;
var a,b,c:array[1..250]of integer; i,n,dem,dem1,sd,vtd,sa,vta,sdcc,sacc,vtd1,vtc1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
dem:=dem+1;
b[dem]:=a[i];
end;
if a[i]<0 then
begin
inc(dem1);
c[dem1]:=a[i];
end;
end;
writeln('So duong dau tien trong day la: ',b[1]);
sd:=b[1];
vtd:=n;
for i:=n downto 1 do
if sd=a[i] then
begin
if vtd>i then vtd:=i;
end;
writeln('Chi so cua no la: ',vtd);
writeln('So am dau tien trong day la: ',c[1]);
sa:=c[1];
vta:=n;
for i:=n downto 1 do
if sa=a[i] then
begin
if vta>i then vta:=i;
end;
writeln('Chi so cua no la: ',vta);
writeln('So duong cuoi cung trong day la: ',b[dem]); sdcc:=b[dem];
vtd1:=1;
for i:=1 to n do
if sdcc=a[i] then
begin
if vtd1<i then vtd1:=i;
end;
writeln('Chi so cua no la: ',vtd1);
writeln('So am cuoi cung trong day la: ',c[dem]); sacc:=c[dem];
vtc1:=1;
for i:=1 to n do
if sacc=a[i] then
begin
if vtc1<i then vtc1:=i;
end;
writeln('Chi so cua no la: ',vtc1);
readln;
end.
Program HOC24;
var i,n,d,d1: integer;
a: array[1..100] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
d:=0; d1:=0;
for i:=1 to n do
begin
if a[i] <0 then d:=d+1;
if a[i]>0 then d1:=d1+1;
end;
writeln('Co ',d,' so duong trong mang');
write('Co ',d1,' so am trong mang');
readln
end,