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 |
Re:我也用的递归In Reply To:我用的不是九进制,我用的是递归的思路,也ac了 Posted by:ccyjava at 2009-08-03 23:08:41 #include <iostream> using namespace std; int main() { int n; while (cin>>n&&n) { int n_temp=n; int q=0; int sum=0; int s=1; int temp; while (n) { temp=n%10; if (temp>=4) { temp=1; } else { temp=0; } temp+=n/10; sum+=temp*(s-q); q=q*9+s; s=s*10; n=n/10; } cout<<n_temp<<": "<<n_temp-sum<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator