K
Khách

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.

16 tháng 12 2020

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.

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.

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.

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,dem;

int main()

{

cin>>n;

dem=0;

for (i=1; i<=n; i++)

{

cin>>x;

if ((x>0) and (x%2==0)) dem++;

}

cout<<dem;

return 0;

}

Câu 1: 

uses crt;

var a:array[1..100]of integer;

i,n: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 

  if a[i]<0 then write(a[i]:4);

readln;

end.

Câu 2: 

uses crt;

var a:array[1..100]of integer;

i,n: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 

  if a[i]>0 then write(a[i]:4);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long x,i,n,t1,dem,t;

int main()

{

cin>>n;

dem=0;

t=0;

t1=0;

for (i=1; i<=n; i++)

{

cin>>x;

t+=x;

if (x>0)

{

dem++;

t1+=x;

}
}

cout<<"So phan tu duong la: "<<dem<<endl;

cout<<"Tong cac so duong la: "<<t1<<endl;

cout<<"Trung binh cong cua day la: "<<fixed<<setprecision(2)<<(t*1.0)/(n*1.0)<<endl;

cout<<"Trung binh cac so duong la: "<<fixed<<setprecision(2)<<(t1*1.0)/(dem*1.0);

return 0;

}

uses crt;

var a:array[1..6]of integer;

i,dem,t:integer;

begin

clrscr;

for i:=1 to 6 do 

  begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

t:=0;

for i:=1 to 6 do 

if a[i]>0 then 

begin

inc(dem);

t:=t+a[i];

end;

writeln('So phan tu duong la: ',dem);

writeln('Tong cac phan tu duong la: ',t);

readln;

end.

2 tháng 5 2022

Var a:array[1..30] of integer;

i,n,d,max:integer;

Begin

Write('Nhap so luong phan tu cua mang ');readln(n);

For i:=1 to n do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

End;

max:=a[1];

For i:=2 to n do

Begin

If a[i] > max then

Begin

max:=a[i];

d:=i;

End;

End;

Write('Phan tu lon nhat la ',max,' o vi tri ',d);

Readln;

End.

2 tháng 5 2022

Var a:array[1..30] of integer;

i,n,d,max:integer;

Begin

Write('Nhap so luong phan tu cua mang ');readln(n);

For i:=1 to n do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

End;

max:=a[1];

For i:=2 to n do

Begin

If a[i] > max then

Begin

max:=a[i];

d:=i;

End;

End;

Write('Phan tu lon nhat la ',max,' o vi tri ',d);

Readln;

End.