Những câu hỏi liên quan
Hoàng Thị Minh Tuyết
Xem chi tiết
Thắng Huỳnh
Xem chi tiết
Tin dễ mà =))
23 tháng 8 2023 lúc 14:17

#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;
}

Bình luận (0)
APOK FF
Xem chi tiết
Felix MC-Gamer
Xem chi tiết
Trần Trọng Hùng
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 3 2022 lúc 11:20

#include <bits/stdc++.h>
using namespace std;
unsigned long long a[1000],i,n,uc;
//chuongtrinhcon
unsigned long long ucln(long long a,long long b)
{
    if (b==0) return(a);
    else return(ucln(b,a%b));
}
//chuongtrinhchinh
int main()
{
    freopen("sn3.inp","r",stdin);
    freopen("uc.out","w",stdout);
    cin>>n;

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

uc=ucln(a[1],a[2]);

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

uc=ucln(uc,a[i]);

cout<<uc;
    return 0;
}

 

Bình luận (1)
Tưởng Ruy Thành
Xem chi tiết
Anh Thư Nguyễn
Xem chi tiết
Nguyễn Đức Anh Khoa
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 1 2021 lúc 12:30

const fi='tong.inp'

fo='tong.out'

var f1,f2:text;

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

n,i,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,t);

close(f1);

close(f2);

end.

Bình luận (0)
Irist Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 4 2021 lúc 19:56

Bài 1: 

const fi='b5.inp.txt'

fo='b5.out.txt'

var f1,f2:text;

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

i,n,kt,j,dem:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

 read(f1,a[i]);

dem:=0;

max:=1;

for i:=1 to n do

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then 

begin

inc(dem);

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

end;

end;

writeln(f2,dem);

if dem=0 then writeln(f2,'Khong co so nguyen to trong day')

else writeln(f2,max);

close(f1);

close(f2);

end.

Bình luận (0)