zoj 2814 Surprising Strings

zoj 2814 Surprising Strings,第1张

zoj 2814 Surprising Strings
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int main(){char s[80];while(scanf("%s",s)){if(strcmp(s,"*")==0)return 0;else{int flag;for(int d = 1 ; d < strlen(s)-1; d++){char **a = new char*[strlen(s)-d];for(int i = 0 ; i < strlen(s)-d; i++){a[i] = new char[2];a[i][0] = s[i];a[i][1] = s[i+d];}flag = 0;for( int j = 0 ; j < strlen(s)-d; j++){for(int k = j+1; k < strlen(s)-d; k++){if(strcmp(a[j],a[k])==0){flag = 1;break;}}if(flag == 1)break;}if(flag == 1)break;}if(flag == 1)cout<<s<<" is NOT surprising."<<endl;elsecout<<s<<" is surprising."<<endl;}}return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4887726.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-11
下一篇 2022-11-11

发表评论

登录后才能评论

评论列表(0条)

保存