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 |
有点明白不过A3B2CCC4AD1232R这个的结果是错的。就WA了#include<iostream> #include<string.h> using namespace std; char str[25]; void f(int i,int n) { cout<<"*"<<i; if(str[i]=='0' || i>n-1) return; else if(str[i]>='1' && str[i]<='9') { str[i]--; f(i+str[i]-'0'+1,n); } else { str[i]=(n-1-i)%10+'0'; f(i+1,n); } } int main() { int i,j,n; char o[20]; while(1) { cin>>o; if(strcmp(o,"ENDOFINPUT")==0) break; cin>>n; cin>>str; cin>>o; f(0,n); cout<<str<<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