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 |
无语,总是wrong ,为什么?#include <iostream> #include <memory.h> #include <vector> #include <string> using namespace std; vector<bool> t; void del(char* b) { int length=strlen(b); char *c=new char[length+1]; char * a=new char[2*length+1]; strcpy(a,b); strcat(a,b); a[2*length]='\0'; int m,n,d,jiajin; bool p; char *q; for(int j=length;j>0;j--) { strcpy(c,b); c[length]='\0'; m=0,n=0,d=0,jiajin=0; for(int i=length-1;i>=0;i--) { d=(c[i]-48)*j; m=d%10; c[i]=(m+n+jiajin)%10+48; jiajin=(m+n)/10; n=d/10; } q=strstr(a,c); if(!q) {p=0;break;} else p=1; } t.push_back(p); delete []a; delete []c; } int main() { vector<char*> c; size_t i; while(1) { bool boo=1; char* b=new char[60]; char *d=b; memset(b,0,60); cin.getline(b,60); if(strlen(b)<2)break; for(i=0;i<60;i++) if(d[i]<48||d[i]>57)break; if(d[i-1]<48||d[i-1]>57)break; c.push_back(b); del(b); } for(i=0;i<c.size();i++) { if(t[i]==0) cout<<c[i]<<" is not cyclic"<<endl; else cout<<c[i]<<" is cyclic"<<endl; } for(i=0;i<c.size();i++) delete c[i]; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator