1. 程式人生 > >數一下 1到 100 的所有整數中出現多少次數字9。

數一下 1到 100 的所有整數中出現多少次數字9。

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i = 0;
	int count = 0;
	while( i<= 100)
	{
		if (i % 10 == 9 ||((i%100)/10)==9)
		{
			count++;
		}
		i++;
	}
	printf("9出現的次數:%d\n",count);
	system("pause");
	return 0;
}