SHARE
TWEET

Untitled

a guest Feb 21st, 2019 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. ///ifstream f("cifre12.in");
  4. ///ofstream g("cifre12.out");
  5. int seg[]={6,2,5,5,4,5,6,3,7,6};
  6. int nr[]={1,5,1,2,2,3,1,2,0,0};
  7. int tot[]={2,7,2,3,3,4,2,5,1,2};
  8. int main()
  9. { unsigned long long n,v;
  10. int s=0;
  11.  cin>>v>>n;
  12.  if(v==1)
  13.  {
  14.      while(n)
  15.      {
  16.          s+=seg[n%10];
  17.          n/=10;
  18.      }
  19.      cout<<s<<"\n";
  20.  }
  21. if(v==2)
  22.  {
  23.    int fr[25];
  24.     unsigned long long solutie = 0;
  25.     int k = 0;
  26.     while(n)
  27.     {
  28.        fr[++k]=n% 10;
  29.         n/=10;
  30.     }
  31.     for(int i=1;i<=k;++i)
  32.     {
  33.         unsigned long long p=nr[fr[i]];
  34.         for(int j = 1; j < i; ++j)
  35.             p=p*tot[fr[j]];
  36.        solutie+=p;
  37.     }
  38.  
  39.     cout<<solutie;
  40.  }
  41.     return 0;
  42. }
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