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[10000],n,i,k,vt;
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++)
cin>>a[i];
vt=0;
for (i=1; i<=n; i++)
if (a[i]==k) vt=i;
cout<<vt;
return 0;
}
Program hotrotinhoc;
var a: array[1..32000] of integer;
i,n,j,tg,k,t: integer;
begin
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('k='); readln(k);
for i:=1 to n do
for j:=i to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
writeln('Day sap xep theo thu tu tang dan la :');
for i:=1 to n do
begin
write(a[i],' ');
if a[i]<k then t:=i;
end;
writeln('Day sau khi chen k : ');
for i:=1 to n do
if (a[i]<k) and (t=i) then write(a[i],' ',k,' ') else write(a[i],' ');
readln
end.
uses crt;
var a:array[1..100]of integer;
k,n,i,tam,x,t:integer;
begin
clrscr;
write('nhap so phan tu:'); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{-----------------------------------------------------}
for i:=1 to n do write(a[i],' ');
{----------------------------------------------------------------}
writeln;
writeln('day tang dan la:');
for i:=1 to n-1 do
for k:=i+1 to n do
if a[i]>a[k] then begin
t:=a[i];
a[i]:=a[k];
a[k]:=t;
end;
for i:=1 to n do write(a[i],' ');
writeln;
{--------------------------------------------}
write('nhap gia tri x:'); readln(x);
i:=1;
while(x>a[i]) and (i<=n) do
i:=i+1;
for k:=n+1 downto i do
a[k]:=a[k-1];
a[i]:=x;
writeln('mang da chen x:');
for i:=1 to n+1 do write(a[i],' ');
readln;
end.
Uses crt;
var n,i,g: integer;
begin clrscr;
readln(n);
g:=0;
for i:=1 to n do if(i mod 2 =0) then g:=g+1;
write(n,' ');
readln;
end.
bài này dễ ẹt à
uses crt;
var a:array[1..100]of integer;
i,n,dem,k:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{-------------------xuat-day----------------------}
for i:=1 to n do
write(a[i]:4);
{------------xu-ly----------------------------------}
writeln;
write('nhap k='); readln(k);
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem=0 then writeln('khong co so ',k,' trong day')
else writeln('so ',k,' xuat hien ',dem,' lan trong day');
readln;
end.