#include<stdio.h> int main(){ int m,n,count; for(m=1000;m<=20000;m++){ n=m; count=0; while(n){ if(n%10==9) count++; n/=10; } if(count==3) printf("%d ",m); } }
#include <stdio.h> int main( void ) { for( unsigned n=1000,index=0; n<=20000; ++n ) { unsigned count = 0; for( unsigned t=n; t; t/=10 ) if( t%10 == 9 ) ++count; if( count == 3 ) printf( "%u%c", n, " \n"[(++index)%8==0] ); } }