Advertisement
Guest User

findthedigit.cxx

a guest
May 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5. int main(){
  6.     int num;
  7.     char digit;
  8.     char chnum[8];
  9.     cout<<"enter a num & a digit to find"<<endl;
  10.     cin >> num;
  11.     cin>> digit;
  12. //  cout << "num%digit"<<num % atoi(&digit)<<endl;
  13.     for (int i=0; i<=abs(num);i++){
  14.         sprintf(chnum, "%i",i);
  15.         for(int j=0;j<strlen(chnum);j++){                  
  16.             if(*(chnum+j)==digit){
  17.                 cout <<i<<endl;
  18.                 break;
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement