比较单一,只能计算100以内的,多了就不行了
#include <stdio.h>
int main ( void )
{
int i ,count ;
for ( i = 1 , count = 0 ; i <= 100 ; i ++ ) {
if ( i % 9 == 0 && i % 10 == 0 ) {
printf ( " %i\n " , i );
count ++;
}
else if ( i % 10 == 9 ) {
printf ( " %i\n " , i ) ;
count ++ ;
}
}
printf ( "出现9的个数为: %i\n " , count );
return 0 ;
}