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.
Bài 1:
uses crt;
var c:aray[1..200]of integer;
i,vt1,vt2:integer;
begin
clrscr;
for i:=1 to 200 do
begin
write('C[',i,']='); readln(c[i]);
end;
for i:=1 to 200 do
if c[i]>0 then
begin
vt1:=i;
break;
end;
if vt1=0 then writeln('Khong co so duong trong day')
else writeln('So duong dau tien trong day la: ',c[vt1],' va chi so cua no la: ',vt1);
for i:=200 downto 1 do
if c[i]>0 then
begin
vt2:=i;
break;
end;
if vt2=0 then writeln('Khong co so duong trong day')
else writeln('So duong cuoi cung trong day la: ',c[vt2],' va vi tri cua no la: ',vt2);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2,sa,sd,vt1,vt2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem1:=0;
t1:=0;
dem2:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then begin inc(dem1); t1:=t1+a[i]; end;
if a[i]<0 then begin inc(dem2); t2:=t2+a[i]; end;
end;
writeln(dem1);
writeln(dem2);
writeln(t1);
writeln(t2);
for i:=1 to n do
if a[i]>0 then
begin
sd:=a[i];
vt1:=i;
break;
end;
if (dem1=0) then writeln('Khong co so duong trong day')
else writeln('So duong dau tien la: ',sd,' vi tri la: ',vt1);
for i:=1 to n do
if a[i]<0 then
begin
sa:=a[i];
vt2:=i;
break;
end;
if (dem2=0) then writeln('Khong co so am trong day')
else writeln('So am dau tien la: ',sa,' vi tri la: ',vt2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
cin>>n;
for (i=1;i<=n; i++) cin>>a[i];
for (i=1;i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n; i++)
if (a[i]%2==0 && a[i]<0) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n; i++)
if (a[i]>0) cout<<a[i]<<" ";
for (i=1; i<=n; i++)
if (a[i]==0) cout<<a[i]<<" ";
for (i=1; i<=n; i++)
if (a[i]<0) cout<<a[i]<<" ";
return 0;
}
uses crt;
var a:array[1..50]of integer;
m,n,t,min,vt:integer;
begin
clrscr;
write('Nhap m='); readln(m);
for i:=1 to m do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to m do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to m do
t:=t+a[i];
writeln('Tong cac phan tu la: ',t);
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
vt:=0;
for i:=1 to n do
if min=a[i] then inc(vt);
writeln('So nho nhat la: ',min);
writeln('So lan xuat hien la: ',vt);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" o vi tri thu "<<i<<endl;
return 0;
}
6:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,A[100],i,dem=0;
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=1;i<=n; i++)
if (A[i]%2!=0) dem++;
cout<<dem;
return 0;
}
5:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,nn=1e6,A[1000];
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=1; i<=n; i++)
nn=min(nn,A[i]);
for (int i=1; i<=n; i++)
if (nn==A[i]) cout<<i<<" ";
return 0;
}
uses crt;
var a:array[1..100]of integer;
n,i,t,nn,kt:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=1;
for i:=1 to n do
if a[i] mod 3=0 then t:=t*a[i];
writeln(t);
kt:=0;
nn:=32567;
for i:=1 to n do
if a[i] mod 3=0 then
begin
if nn>a[i] then nn:=a[i];
kt:=1;
end;
if kt=0 then writeln('Khong co so chia het cho 3')
else writeln('So nho nhat chia het cho 3 la: ',nn);
for i:=1 to n do
if nn=a[i] then write(i:4);
writeln;
for i:=n downto 1 do
write(a[i]:4);
readln;
end.
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.