fahimkamal63

Make a Distinct Digit Array

Apr 18th, 2019
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int t; cin >> t;
  6.     while(t--){
  7.         int n, i; cin >> n;
  8.         unsigned long long int a[n];
  9.         for(i = 0; i < n; i++) cin >> a[i];
  10.         int digits[10] = {0};
  11.         for(i = 0; i < n; i++){
  12.             int k = a[i];
  13.             while(k){
  14.                 int m = k % 10;
  15.                 digits[m] = 1;
  16.                 k /= 10;
  17.             }
  18.         }
  19.         for(i = 0; i < 10; i++){
  20.             if(digits[i] != 0) cout << i << ' ';
  21.         }
  22.         cout << endl;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment