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 <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n,k;
cin >> n >> k;
int a[n];
for (int i=0;i<n;i++)
cin >> a[i];
sort(a,a+n);
cout << a[k-1];
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
freopen("namnhuan.inp","r",stdin);
freopen("namnhuan.out","w",stdout);
cin>>n;
if ((n%400==0) or (n%4==0 && n%100!=0)) cout<<366;
else cout<<365;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,dem,i;
int main()
{
freopen("bl1.inp","r",stdin);
freopen("bl1.out","w",stdout);
cin >> n;
for( i = 2; i <= n; i++)
{
dem = 0;
while(n % i == 0)
{
++dem;
n=n/i;
}
if(dem)
{
cout<<i;
if (dem>1) cout <<"^"<<dem;
if (n>i){
cout <<" * ";
}
}
}
return 0;
}
uses crt;
var a:array[1..100]of integer;
n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Day so A ban vua nhap la: ');
for i:=1 to n do
write(a[i],' ');
writeln;
t:=0;
for i:=1 to n do
if (a[i] mod 3=0) and (a[i] mod 5<>0) then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 3 va khong chia het cho 5 la: ',t);
readln;
end.
Bạn tham khảo code này nhé.
Uses crt;
Const fo = 'chenxau.out';
dau: array[1..3] of String[1]= ('','-','+');
s:array[1..9] of char=('1','2','3','4','5','6','7','8','9');
Var d:array[1..9] of String[1];
m:longInt;
f:text;
k:integer;
found:boolean;
Procedure Init;
Begin
Write('Cho M=');
Readln(m);
found:=false;
end;
Function tinh(s:string):longint;
Var i,t:longint;
code:integer;
Begin
i:=length(s);
While not(s[i] in ['-','+']) and (i>0) do dec(i);
val(copy(s,i+1,length(s)-i),t,code);
If i=0 then begin tinh:=t; exit; end
else
begin
delete(s,i,length(s)-i+1);
If s[i]='+' then tinh:=t+tinh(s);
If s[i]='-' then tinh:=tinh(s)-t;
end;
End;
Procedure Test(i:integer);
Var st:string; j:integer;
Begin
st:='';
For j:=1 to i do st:=st+d[j]+s[j];
If Tinh(st) = m then begin writeln(f,st); found:=true; end;
End;
Procedure Try(i:integer);
Var j:integer;
Begin
for j:=1 to 3 do
begin
d[i]:=dau[j]; Test(i);
If i<9 then try(i+1);
end;
End;
BEGIN
Clrscr;
Init;
Assign(f,fo);Rewrite(f);
for k:=1 to 2 do
begin
d[1]:=dau[k];
Try(2);
end;
If not found then write(f,'khong co ngiem');
Close(f);
END.
C++ nha mn