Những câu hỏi liên quan
Huyền Trang
Xem chi tiết
Lala
Xem chi tiết
Trương Huy Hoàng
13 tháng 12 2023 lúc 22:58

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("MAP1.INP","r",stdin);
    freopen("MAP1.OUT","w",stdout);
    ll n; cin >> n;
    ll a[n+5];
    for(ll i=1;i<=n;i++) cin >> a[i], mp[a[i]]++;
    for(pair<ll,ll> it:mp) cout << it.first << " " << it.second << "\n";
}

Chúc bạn học tốt!

Bình luận (0)
Sự tâm
Xem chi tiết
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:49

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

freopen("dayd.inp","r",stdin);

freopen("dayd.out","w",stdout);

cin>>n;

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

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

if (a[i]>0) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Hello1234
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 10 2021 lúc 15:00

#include <bits/stdc++.h>

using namespace std;

int main()

{

long a[105], i,n,max,vt;

cout<<"n="; cin>>n;

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

{

cout<<"A["<<i<<"]="; cin>>a[i];

}

max=a[1];

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

if (max<a[i]) max=a[i];

vt=1;

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

if (max==a[i]) vt=i;

cout<<max<<endl;

cout<<vt;

return 0;

}

 

Bình luận (1)
26-Do Thanh Trung
Xem chi tiết
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 1 2023 lúc 14:46
const fi='chuso.inp'      fo='chuso.out'var f1,f2:text;    i,n:integer;    a:array[1..100] of integer;//chuongtrinhconfunction dai(x:integer)var st:string;    d:integer;beginstr(x,st);d:=length(st);dai:=d;end;//chuongtrinhconfunction tong(x:integer)var i,n,d,t,y:integer;    st:string;begin   str(x,st);   d:=length(st);   t:=0;   for i:=1 to d do    begin    val(st[i],n,y);    t:=t+n;    end;   tong:=t;end;//chuongtrinhchinhbeginassign(f1,fi); reset(f1);assign(f2,fo); rewrite(f2);readln(f1,n);for i:=1 to n do  read(f1,a[i]);for i:=1 to n do      writeln(f2,dai(a[i]),' ',tong(a[i]));    close(f1);    close(f2);end.
Bình luận (0)
Mộng Chúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 10:03

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,j;

bool kt;

int main()

{

freopen("nguyento.inp","r",stdin);

freopen("nguyento.out","w",stdout);

cin>>n;

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

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

if (a[i]>1) 

{

kt=true;

for (j=2; j*j<=a[i]; j++)

if (a[i]%j==0) kt=false;

if (kt==true) cout<<a[i]<<" ";

}

return 0;

}

Bình luận (0)
Lê Phương Thảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 21:55

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.

Bình luận (0)