我的做法:
#include <stdio.h>
int Magic(int m);
int main()
{
int m, ret;
printf("Input a sum:");
scanf("%d", &m);
ret = Magic(m);
if (ret != 1)
{
printf("The sum you calculated is wrong!\n");
}
return 0;
}
int Magic(int m)
{
int a, b, c, n;
for (a = 1; a < 9; a++)
{
for (b = 1; b < 9; b++)
{
for (c = 1; c < 9; c++)
{
n = 122 * a + 212 * b + 221 * c;//本质上是五种组合加在一起
if (m == n)
{
printf("The number is %d\n", 100 * a + 10 * b + c);
return 1;
}
}
}
}
return 0;
}
标签:return,猜数,int,ret,魔术,CP1250,printf,Magic
From: https://www.cnblogs.com/harumakigohan686/p/17023818.html