#include
#include
int zhd(long);
long fac(int);
void main()
{
int n,a=0;
long i;
printf("input 'n':");
scanf("%d",&n);
for(i=pow(10,(n-1));i
{
printf("%ld\n",i);
a=1;
}
if(!a)
printf("No output\n");
}
int zhd(long n)
{
int i;
long s=0,m=n;
do{
i=m%10;
s+=fac(i);
m/=10;
}while(m);
if(n==s)return 1;
return 0;
}
long fac(int n)
{
long s;
if(!n)s=1;
else s=n*fac(n-1);
return s;
}
/*下面是我帮你改正的(错误有以下几点):
1,main函数前要有说明;
2,定义函数,且此函数在main函数之后,则要在main函数之前做说明;
3,if等语句后有多个语句是要用大括号;
4,类型不符合的作一下强制说明比较好。
*/
#include
#include
int jc(int a);
void main()
{
int n,i,j,k=0,m,a=0,b=0;
scanf("%d",&n);
for(i=(int)pow(10,n-1);i<(int)pow(10,n);i++)
{
for(j=1,k=0;j<=n;j++)
{m=(int)pow(10,j-1);
a=i/m%10;
k+=jc(a);
a=0;}
if(k==i){
printf("%d\n",i);
b++; }
}
if(b==0) printf("No output\n");
}
int jc(int a)
{int x; long y=1;
if(a==0) return y;
else for(x=1;x<=a;x++)
y*=x;
return y;
}
for(j=1;k=0,j<=n;j++)
这句造成循环失效
#include
#include
int jc(int a)
{int x;
int y=1;
if(a==0) return y;
else for(x=1;x<=a;x++)
y*=x;
return y;
}
void main()
{
int n,j,a=0,k=0,b=0;
double i,m;
scanf("%d",&n);
for(i=pow(10,n-1);k=0,i
for(j=1;j<=n;j++)
{m=pow(10.,int(j-1));
a=int(i/m)%10;
k+=jc(a);
}
if(k==int(i)) {
printf("%d\n",k);
b++;
}
}
if(b==0) printf("No output\n");
}
#include
#include
#include
const int values[10] = {1, 1, 2, 6, 24, 120, 720,
5040, 40320, 362880};
int getsum(char* ch, int len)
{
int i = 0, sum = 0;
while(i < len)
{
sum += values[ch[i] - '0'];
i++;
}
return sum;
}
int main(void)
{
int n, low, high, i;
int isOK = 0;
char* pch = 0;
scanf("%d",&n);
low = (int)pow(10, n - 1);
high = 10 * low;
pch = (char*)malloc(n);
for(i = low; i < high; i++)
{
sprintf(pch,"%d",i);
if(getsum(pch, n) == i)
{
isOK = 1;
printf("%s\n",pch);
}
}
if(!isOK)
printf("No output\n");
free(pch);
return 0;
}