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 |
贴个代码,9进制#include<stdio.h> int n; int pow(int a,int b) { if(b==0) return 1; else return a*pow(a,b-1); } int wei(int n) { if(n<10) return 1; else return 1+wei(n/10); } int kan(int n,int i) { if(i==1) { if(n<4) return n; else return n-1; } else { int w=pow(10,i-1),z=n/w,q=n%w; return kan(z,1)*pow(9,i-1)+kan(q,i-1); } } int main() { while(scanf("%d",&n),n) { printf("%d: %d\n",n,kan(n,wei(n))); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator