¸øÒ»¸ö×Ö·û´®¡¢ÀýÈç ¡°ababc¡±ÒªÇ󷵻ء°ab¡±. ÒòΪ¡°ab¡±Á¬ÐøÖظ´³öÏÖÇÒ×¡£ ÓÃC/C£«£«ÓïÑÔдһº¯ÊýÍê³É¸ÃËã·¨£¬¸ø³ö¸´ÔÓ¶È
Õâ¸öÌâÎÒ²»»á
C/C++ code:
#include <iostream>
#include <string>
using namespace std;
bool getmaxsubstr(const string& s, string& oks);
int main()
{
string str;
while (cin >> str)
{
string s;
if (getmaxsubstr(str, s))
{
cout << s << endl;
}
else
{
cout << "do not exist!\n";
}
}
return 0;
}
bool getmaxsubstr(const string& s, string& oks)
{
string rets;
int len = 0;
bool bf = false;
for (int i = 0; i < s.size(); ++i)
{
for (int j = 1; j <= s.size() - i; ++j)
{
rets = s.substr(i, j);
if (s.find(rets, i + j) != string::npos && rets.size() > len)
{
len = rets.size();
oks = rets;
bf = true;
}
}
}
return bf;
}
O(n^2),ûÓп¼ÂÇsubstrÄÚ²¿µÄ¸´ÔӶȡ£
ÎÊÌâÒªÇóÄÜ·ñÔÙÇåÎúһЩ
±ÈÈ磺"aababcabcd"µÄÇé¿öÏ£¬ab³öÏÖÁË3´Î£¬¶øabc³öÏÖÁË2´Î£¬Ó¦¸Ã·µ»ØÄÄÒ»¸ö£¿
#include <stdio.h>
#define BUF_MAX 1000
Ïà¹ØÎÊ´ð£º
C/C++ code:
#include <stdio.h>
typedef struct node{
int *key;
int length;
}node;
void insert(node &temp,int n)
{
int i,j;
for(i=0;i<=temp.length;i++)
{
......
1001.exe ÖÐµÄ 0x0041394f ´¦Î´´¦ÀíµÄÒì³£: 0xC0000005: дÈëλÖà 0x66792e62 ʱ·¢Éú·ÃÎʳåÍ»
ÕâÊÇÔõô»ØÊ£¿Ð»Ð»ÁË£¬ÎÒÊDzËÄñ
ËÖªµÀÔõô»ØÊ¡¡ÕâÊǸöͨÓõĴíÎóÌáʾ¡¡ÉÏ´úÂë
ÐèÒªÖØнøÐбàÒë
Ò ......
char data[255]={0},user[15],password[32];
if((fp=fopen("QQ.ini","wb+"))==NULL)
{
printf("ÎÞ·¨´´½¨QQ.iniÎļþ\n");
system("pause");
exit(0); ......
Ò»¸öÊýÈç¹ûºÃµÈÓÚËüµÄÒò×ÓÖ®ºÍ£¬Õâ¸öÊý¾Í³ÉΪ"ÍêÊý",ÀýÈç6µÄÒò×ÓΪ1£¬2£¬3¶ø6=1+2+3,¶ø6=1+2+3,Òò´Ë6ÊÇ¡°ÍêÊý".±à³ÌÐòÕÒ³ö1000Ö®ÄÚµÄËùÓÐÍêÊý£¬²¢°´ÏÂÃæ¸ñʽÊä³öÆäÒò×Ó£º6 its factors are 1,2,3
......
c/s ºÍb/s µÄÇø±ðÊÇʲô£¬c/sÐèÒª·þÎñÆ÷Âð£¬ÔõôÅжϳÌÐòÊÇc/s »¹ÊÇb/s
C/SÊÇ·þÎñÆ÷ºÍ¿Í»§¶Ë B/SÊÇ·þÎñÆ÷ºÍä¯ÀÀÆ÷
ËûÃǶ¼ÓÐs£¬Ê²Ã´ÊÇs?¾ÍÊÇserver
ÄÇËûÃǵÄÇø±ðÊÇʲô£¿Ò»¸öÊÇc£¬¼´client£¬Ò»¸ö ......