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 |
怎么超时呀?请大家帮我看看有什么改动的地方,我刚学字符串的使用。#include <iostream> using namespace std; int main() { char a[2000][44]; char b[2000][44]; int ji[1000]={0}; int many=0; while (gets(a[many])!=NULL){ many+=1; //printf("%d\n",many); // getchar(); } //system("pause"); for (int i=0;i<many;i++) { ji[i]=0; bool can; can=false; while ((can==false)&&(ji[i]<strlen(a[i]))) { ji[i]+=1; strncpy(b[i],a[i]+0,ji[i]); // printf("%s\n",b[i]); //system("pause"); can=true; for (int j=0;j<many;j++) if (j!=i) { bool neng; neng=false; for (int yi=0;yi<strlen(b[i]);yi++) if (b[i][yi]!=a[j][yi]) neng=true; if (neng==false) can=false; } } printf("%s %s\n",a[i],b[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