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.

#include <bits/stdc++.h>

using namespace std;

long long a[200],i,n,k;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

cin>>k;

kt=false;

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

if (a[i]==k)

{

cout<<i<<" ";

kt=true;

}

cout<<endl;

if (kt==false) cout<<"Khong co so k trong day"<<endl;

sort(a+1,a+n+1);

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

24 tháng 8 2021
Uses crt;

Var i,k,n,bk,tong: integer;

a: array[1..1000] of integer;

Begin

write('Nhap K: '); readln(k);

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

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

end;

{câu a}

For i:=1 to n do 

if a[i]=k then bk:=bk+1;

writeln('Co so phan tu bang k la:',k);

{câu b}

For i:=1 to n do 

if a[i]=k then

begin

write(i,' ');

tong:=tong+a[i];

end;

write('. Tong la:',tong);

readln

end.

31 tháng 8 2021

uses crt;
var k,n,tong,d,i:longint;a:array[1..1000]of longint;
begin
 clrscr;
  write('n=');readln(n);
  write('k=');readln(k);
  for i:=1 to n do
        begin
         write('a[',i,']=');readln(a[i]);
        end;
  d:=0;
  for i:=1 to n do if(a[i]=k)then inc(d);
  writeln('so phan tu bang voi:',k,' la:',d);
  write('cac so co vi tri bang voi:',k,' la:');
  tong:=0;
  for i:=1 to n do if(a[i]=k)then
        begin
         write(i,' ');
         tong:=tong+a[i];
        end;
  write('tong cua cac so bang voi:',k,' la:',tong);
 readln;
end.

#include <bits/stdc++.h>

using namespace std;

long long a[40],i,n,ln;

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]);

for (i=n; i>=1; i--)

if (ln==a[i]) 

{

cout<<i;

break;

}

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: 

uses crt;

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

i,n,kt,max,x,j,tam:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

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

end;

writeln('Mang ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

for i:=1 to n-1 do 

  for j:=i+1 to n do 

if a[i]>a[j] then 

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

writeln('Day tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

write('Nhap x='); readln(x);

max:=0;

kt:=0;

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]<=x) then 

   begin

  if max<a[i] then max:=a[i];

kt:=1;

end;

if kt=0 then writeln('Trong day khong co so le')

else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

uses crt;

var a:array[1..10]of longint;

n,i,t,dem,dem1,dem2,t1:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

20 tháng 1 2022

uses crt;

var a:array[1..10]of longint;

n,i,t,dem,dem1,dem2,t1:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.