【C语言】编写程序数一下1到100的所有整数中出现多少次数字9

#define _CRT_SECURE_NO_WARNINGS 1
//编写程序数一下1到100的所有整数中出现多少次数字9,注意是出现9的次数。

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i = 0;
	int count = 0;
	for (i = i; i <= 100; i++)
	{
		if (i % 10 == 9)
			count=count+1;
		if (i/10 == 9)
			count = count + 1;
	}
	printf("count=%d\n", count);
	system("pause");
	return 0;

}

猜你喜欢

转载自blog.csdn.net/qq_41562665/article/details/80646336
今日推荐