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..250]of integer;
i,n,dem,t,t1,t2,t3,t4:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=250);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until (0<a[i]) and (a[i]<=500);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2=1 then inc(dem);
writeln('So phan tu co gia tri le la: ',dem);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu co chi so chan la: ',t);
t1:=0;
for i:=1 to n do
if i mod 2=1 then t1:=t1+a[i];
writeln('Tong cac phan tu co chi so le la: ',t1);
t2:=0;
for i:=1 to n do
if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];
writeln('Tong cac phan tu chan co chi so chan la: ',t2);
t3:=0;
for i:=1 to n do
if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];
writeln('Tong cac phan tu co chi so le la: ',t3);
t4:=0;
for i:=1 to n do
t4:=t4+a[i];
writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[250],ln,i,n;
int main()
{
cin>>n;
for (i=1;i<=n; i++) cin>>a[i];
ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
cout<<ln<<endl;
for (i=1; i<=n; i++) if (ln==a[i]) cout<<i<<" ";
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[250],i,n,k;
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]==k) cout<<i<<" ";
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[250],i,n,k;
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]==k) cout<<i<<" ";
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[250],i,n,k;
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]==k) cout<<i<<" ";
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[250],i,n,k;
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]==k) cout<<i<<" ";
return 0;
}
uses crt;
var a:array[1..1000]of integer;
i,n,k,dem: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);
for i:=1 to n do
if a[i]=k then
begin
writeln(i);
break;
end;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem>0 then writeln('Co ',dem,' phan tu bang ',k)
else writeln('Khong co phan tu nao bang ',k);
readln;
end.
uses crt;
var a,vt:array[1..250]of integer;
i,n,max,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=250);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=500;
end;
max:=a[1];
dem:=0;
for i:=1 to n do
if max<a[i] then max:=a[i];
for i:=1 to n do
if max=a[i] then
begin
inc(dem);
vt[dem]:=i;
end;
writeln('Gia tri lon nhat la: ',max);
write('Vi tri: ');
for i:=1 to dem do
write(vt[i]:4);
readln;
end.