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,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.
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..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 b[20],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>b[i];
for (i=1; i<=n; i++)
{
if ((b[i]%2!=0) or (i%2==0)) cout<<b[i]<<" ";
}
return 0;
}
#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: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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
cout<<"Cac so duong la: ";
for (i=1; i<=n; i++) if (a[i]>0) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n; i++) if (a[i]%2==0) cout<<a[i]<<" ";
for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<a[i]<<" ";
return 0;
}
#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;
}
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.