Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. //Pb1
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void citire(int &n, int a[])
  6. {
  7. cin >> n;
  8. for(int i = 1; i <= n; ++i)
  9. cin >> a[i];
  10. }
  11.  
  12.  
  13. int cifEgale(int n)
  14. {
  15. int uc = n % 10;
  16. n /= 10;
  17. while(n > 0)
  18. {
  19. if(uc != n % 10)
  20. return 0;
  21. n /= 10;
  22. }
  23. return 1;
  24.  
  25. }
  26.  
  27. int cateEgale(int n, int a[])
  28. {
  29. int cnt = 0;
  30. for(int i = 1; i < n; ++i)
  31. for(int j = i + 1; j <= n; ++j)
  32. if(cifEgale(a[i] + a[j]))
  33. cnt++;
  34. return cnt;
  35. }
  36.  
  37. int main()
  38. {
  39. int n, a[100001];
  40. citire(n, a);
  41. cout << cateEgale(n, a);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement