编写程序,统计1-100,阿拉伯数字“5”出现的次数

C语言 码拜 8年前 (2016-04-10) 1081次浏览
编写程序,统计1-100,阿拉伯数字“5”出现的次数
解决方案

40

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

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明编写程序,统计1-100,阿拉伯数字“5”出现的次数
喜欢 (0)
[1034331897@qq.com]
分享 (0)