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 |
这个题为啥wa,帮忙看看,谢谢#include<iostream> using namespace std; char s[100]; bool cylenum(int len) { int i,hlen=(len>>1),even; even=len%2; for(i=0;i<hlen;i++) { if(s[i]+s[hlen+i+even]-'0'=='9')continue; else break; } if(len%2==0&&i==hlen) return true; if(len%2&&i==hlen&&s[hlen]=='9') return true; else return false; } bool allzero(int len) { int i; for(i=0;i<len;i++) { if(s[i]!='0')return false; } return true; } int main() { freopen("in.txt","r",stdin); while(scanf("%s",s)!=EOF) { int len=strlen(s); if(strcmp(s,"1")==0||allzero(len)) { printf("%s is cyclic\n",s); continue; } if(cylenum(len))printf("%s is cyclic\n",s); else printf("%s is not cyclic\n",s); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator