Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
补充一个递归的想法#include "stdio.h" long an(long n) { long k=1,nn=n,sum1=0,sum2=0; if(n<4) return n; if(n>4&&n<10) return n-1; while(nn){ if(nn%10>4) sum2+=k; nn/=10; sum1+=an(nn)*k; k*=10; } return n-sum1-sum2; } void main() { long n; scanf("%ld",&n); while(1){ if(n==0) break; printf("%ld: %ld\n",n,an(n)); scanf("%ld",&n); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator