Untitled
raw download clone
TEXT
views 20
,
size 497 b
#include <iostream>
using namespace std;

int main()
{
    int n , s , p=1 , sc , cnt=0;

    cin >> n >> s;

    while(n)
    {
        p=p*10;
        n--;
    }

    for(int x=p/10 ; x<p ; x++)
    {
        n=x;
        sc=0;
        while(n)
        {
            sc=sc+n%10;
            n=n/10;
        }
        if(sc==s)
            cnt++,cout << x << " ";
    }
    if(cnt==0)
        cout << cnt;
    else 
        cout << endl << cnt;


    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.