#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
int a[100] = { 5650,4542,3554,473,946,4114,3871,9073,90,4329,
2758, 7949 ,6113, 5659, 5245, 7432, 3051 ,4434 ,6704 ,3594,
9937 ,1173, 6866 ,3397, 4759 ,7557 ,3070 ,2287, 1453, 9899,
1486 ,5722, 3135 ,1170 ,4014, 5510 ,5120, 729, 2880, 9019,
2049 ,698 ,4582 ,4346 ,4427 ,646, 9742 ,7340 ,1230 ,7683,
5693 ,7015, 6887 ,7381, 4172 ,4341, 2909, 2027 ,7355 ,5649,
6701 ,6645, 1671 ,5978 ,2704 ,9926 ,295, 3125 ,3878, 6785,
2066 ,4247 ,4800 ,1578, 6652, 4616 ,1113, 6205 ,3264 ,2915,
3966 ,5291 ,2904, 1285, 2193 ,1428 ,2265, 8730, 9436, 7074,
689 ,5510 ,8243 ,6114 ,337 , 8199 ,7313 ,3685 ,211 };
int i = 0;
int k = 0;
int co2 = 0;
int co5 = 0;
for (i = 0; i < 100; i++)
{
k = a[i];
while (k % 2 == 0)
{
if (k == 0)
{
break;
}
co2++;
k = k / 2;
}
while (k % 5 == 0)
{
if (k == 0)
{
break;
}
co5++;
k = k / 5;
}
}
if (co2 > co5)
{
printf("%d", co5);
}
else
{
printf("%d", co2);
}
return 0;
}
0就是2*5=10;的个位数
首先建立一个容量为100的数组
然后通过for循环遍历数组,
通过while循环判断有几个2与5;
|