daily pastebin goal
24%
SHARE
TWEET

findthedigit.cxx

a guest May 16th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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