Find Digits

https://www.hackerrank.com/challenges/find-digits/problem 

#include <bits/stdc++.h>

using namespace std;
void findDigits(int n) {
    int count=0;
    int num=n;
    while(n>0){
        int last=n%10;
        if(last!=0 && num%last == 0)
         count++;
        n=n/10;
    }
    cout<<count<<endl;
}
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        int no;
        cin>>no;
        findDigits(no);
    }
    
    return 0;
}

Comments

Popular posts from this blog

Perfect Peak of Array

Is Rectangle?

Sort array with squares!