恩恩 有点乱
不要不要的。。。
int GetVal(int a) { int i = 0, s = 1; int temp = a; int wei = GetWei(a); while (1) { s = 1; for (i = 0; i < wei - 1; i++) { s = s * 10; } a = a % s; if (a == 0) { temp = temp / s; break; } else if (a > 0 && a < 10) { temp = a; break; } else { temp = a; } wei = GetWei(a); } return temp; } int GetWei(int a) { int i = 1; int temp = a; while (temp = temp / 10) { i++; } return i; } int Fun(int a) { if (a == 1) return 1; return (a*Fun(a - 1)); } int main() { int result; int a; printf("请输入一个正整数:"); while (scanf("%d",&a)!=1) { printf("输入的数字不是正整数,请重新输入一个正整数\n"); getchar(); } result = GetVal(Fun(a)); printf("%d\n", result); return 0; }