Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. int rec(int L[], int N, int F [] ) {
  6.     int Kath=N;
  7.     int Deg=0;
  8.     if (N==0)
  9.         return 0;
  10.        
  11.     while (Kath>=10){
  12.         Kath=Kath%10;
  13.         Deg++;
  14.     }
  15.    
  16.     if (Kath==0)
  17.         return rec(L, N%10, F);
  18.        
  19.     for (int i=0;i<10; i++){
  20.         if (i>=Kath-1)
  21.             L[i]=L[i]+F[Deg]*(Kath-1)+pow(10,Deg);
  22.         else
  23.             L[i]=L[i]+F[Deg]*(Kath-1);
  24.     }
  25.     return rec(L, N%10, F);
  26. }  
  27. int main(){
  28.     ios_base::sync_with_stdio(false);
  29.     cin.tie(0);
  30.    
  31.     int N;
  32.     int F[4];
  33.     F[0]=0;
  34.     F[1]=1;
  35.     F[3]=20;
  36.     F[4]=300;
  37.     int L[10];
  38.     for (int i=1; i<N; i++)
  39.         L[i]=0;
  40.     cin>>N;
  41.    
  42.     rec(L, N, F);
  43.     for (int i=0; i<10; i++){
  44.         cout << L[i] << endl ;
  45.     }
  46.     return 0;
  47. }
  48. //?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement