Những câu hỏi liên quan
89654DAUUBUOIIIII956
Xem chi tiết
Phía sau một cô gái
26 tháng 7 2023 lúc 19:45

#include <iostream>

#include <map>

using namespace std;

int main() {

       int n;

       cin >> n;

       map<int, int> count;

       for (int i = 0; i < n; i++) {

              int x;

              cin >> x;

              count[x]++;

       }

       int ans = 0;

       for (auto p : count) {

              int x = p.second;

              ans += (x * (x - 1)) / 2;

       }

       cout << ans;

       return 0;

}

Bình luận (1)
Thu Hiền
Xem chi tiết
Hoài Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 10 2021 lúc 15:14

a: #incldue <bits/stdc++.h>

using namespace std;

long long i,n,x,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if (x>0) t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)
shushu333
Xem chi tiết
Nguyên Hưng Trần
25 tháng 10 2021 lúc 21:19

program Tin_hoc;

Uses crt;

var i,n,k,dem:integer;

     a;array[1..10000] of integer;

Begin

clrscr;

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

writeln('Nhap ',n,' pha tu cua day A:');

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

dem:=0;

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

for i:= 1 to n do if a[i] = k then inc(dem);

writeln('Day A co ',dem,' ki tu ',k,);

readln;

end.

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)
Nhật Minh
Xem chi tiết
Nhật Minh
Xem chi tiết
Nhật Minh
Xem chi tiết
Nguyễn Lê
Xem chi tiết
Minh Lệ
19 tháng 2 2023 lúc 20:34

Bài 1:

Program HOC24;

var i,n,d : byte;

t: integer;

begin

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

for i:=1 to n do 

begin

write('Nhap phan tu thu ',i,' : '); readln(a[i]);

end;

for i:=1 to n do if (a[i] mod 3=0) and (a[i] mod 5=0) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' phan tu la boi cua 3 va 5');

write('Tong la: ',t);

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 2 2023 lúc 20:38

Bài 2:

Program HOC24;

var i,n,k : byte;

begin

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

for i:=1 to n do 

begin

write('Nhap phan tu thu ',i,' : '); readln(a[i]);

end;

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

for i:=1 to n do if a[i]=k then d:=d+1;

writeln('Co ',d,' phan tu bang ',k);

Write('Cac chi so do la: ');

for i:=1 to n do if a[i]=k then write(i,' ');

readln

end.

Bình luận (1)
Nguyễn Lê
12 tháng 4 2023 lúc 19:13

loading...  loading...  giúp em 4 bài này vs ạ 

Bình luận (0)