满意答案
litielige
2016.11.20
采纳率:48% 等级:7
已帮助:515人
#include
long fun(long s)
{
int sum = 0;
long fin = 0,flag = 0;
int a[20] = {0};
for(int i =1; (s/i) != 0; i = i * 10)
++sum;
int temp = i;
for(int j = 0; j < sum; j++)
{
temp = temp / 10;
a[j] = s / temp;
s = s % temp;
}
for(int k = 0; a[k] >= 0; k++)
{
for(j = 0; j < sum-k-1; j++)
{
if(a[j] > a[j+1])
{
int t;
t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}
}
}
j = 0;
i = 1;
while(j < sum)
{
if(a[j] % 2 == 0)
{
if(a[j] == 0)
{
if(j == 0) ;
else
{
flag = 1;
fin = i*10;
}
}
else
if(flag)
{
fin *= a[j];
flag = 0;
}
else
fin += a[j] * i;
i *= 10;
}
j++;
}
return fin;
}
int main()
{
long s,final ;
scanf("%ld",&s);
final = fun(s);
printf("%ld\n",final);
return 0;
}
03分享举报