编写程序数一下1-100的所有整数中出现多少次数字9

#include<stdio.h>
#include<stdlib.h>
main()
{
	int i=1,a=0;
	for (i = 1; i < 100; i++)
	{
		if ((i / 10) == 9 || (i % 10) == 9)
			a = a + 1;
	}
	printf("%d", a);
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq940051592/article/details/84575747