Advertisement
velimir

stranica

Apr 6th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int br, i, temp, tempc, brc, brrk, min, fakebool=1, raz;
  8.     cin>>br>>brrk;
  9.     int zafateni[10];
  10.     for(i=0;i<brrk;i++)
  11.     {
  12.         cin>>zafateni[i];
  13.     }
  14.     min=br-100;
  15.     for(temp=br;temp<10000000;temp++)
  16.     {
  17.         fakebool=1;
  18.         for (tempc=temp; fakebool==1;tempc/=10)
  19.         {
  20.             if(tempc==0) break;
  21.             for(i=0;i<brrk;i++)
  22.             {
  23.                 if(zafateni[i]==tempc%10){ fakebool=0; break; }
  24.             }
  25.         }
  26.         if (fakebool==1) break;
  27.     }
  28.     raz=(temp-br);
  29.     for(brc=0;temp;temp/=10)brc++;
  30.     if (brc+raz<min)min=(brc+raz);
  31.  
  32.     for(temp=br;temp>0;temp--)
  33.     {
  34.         fakebool=1;
  35.         for (tempc=temp; fakebool==1;tempc/=10)
  36.         {
  37.             if(tempc==0) break;
  38.             for(i=0;i<brrk;i++)
  39.             {
  40.             if(zafateni[i]==tempc%10){ fakebool=0; break;}
  41.             }
  42.         }
  43.         if (fakebool==1) break;
  44.     }
  45.     raz=(br-temp);
  46.     for(brc=0;temp;temp/=10) brc++;
  47.     if(brc+raz<min)min=(brc+raz);
  48.     cout<<min;
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement