daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. void readarr(int n, int *arr){
  7.     for (int i = 0; i < n; i++){
  8.         cin >> arr[i];
  9.     }
  10. }
  11.  
  12. void bub(int *arr, int n){
  13.     for (int i = 0; i < n; i++){
  14.         for (int j = 0; j < n; j++){
  15.             if (arr[j] > arr[j + 1]){
  16.                 swap(arr[j], arr[j+1]);
  17.             }
  18.         }
  19.     }
  20. }
  21.  
  22. int raz(int n){
  23.     int raz = 0;
  24.     while (n != 0){
  25.         raz++;
  26.         n/=10;
  27.     }
  28.     return raz;
  29. }
  30.  
  31. int *numtoarr(int n){
  32.     int *tmp = new int[raz(n)];
  33.     int i = 0;
  34.     while (n!=0){
  35.         tmp[i] = n%10;
  36.         i++;
  37.         n/=10;
  38.     }
  39.     return tmp;
  40. }
  41.  
  42. int main(){
  43.     int n, a;
  44.     cin >> n;
  45.     int arr[100] = {};
  46.     readarr(n, arr);
  47.     int res = 0;
  48.  
  49.     for (int i = 0; i < n; i++){
  50.         int *num = numtoarr(arr[i]);
  51.         int s = raz(arr[i]);
  52.         for (int j = 0; j < s; j++){
  53.             if (num[j] == num[j+3] && num[j+1] == num[j+2]  && num[j] != num[j+1] && num[j] != num[j+2]){
  54.                 res++;
  55.                 break;
  56.             }
  57.         }
  58.         delete[]num;
  59.     }
  60.     cout << res;
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top