编写程序,统计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");
}