Untitled
raw download clone
TEXT
views 19
,
size 573 b
#include<iostream>
using namespace std;
int cifn(int n)
{
    if(n)
        return n % 10 + cifn(n / 10);
        return 0;
}
int main()
{
    int n , s , k = 0 , maxi = 9 , m = 1 , aux;
    cin >> n >> s;
    for(int i = 2;  i <= n;  i++)
      {
            m = m * 10;
            maxi = maxi * 10 + 9;
      }
    aux = cifn(m);


    for(int i = m ; i <= maxi; i++)
    {
        if(cifn(i) == s)
        {
            cout << i << " ";
            k++;
        }
    }
    if(k!= 0)
    cout <<'\n' <<  k;
    else
        cout << 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.