[ create a new paste ] login | about

Link: http://codepad.org/OPoY0Pu4    [ raw code | output | fork ]

C++, pasted on Jul 20:
1
2
3
4
5
6
7
8
9
10
11
12
void Z_maker( int z[], char s[], int n ){
	z[0] = n;
	int L = 0, R = 0, i, x;
	for( i = 1 ; i < n ; i++ ){
		if( R < i || z[i-L] >= R-i+1 ){
			R < i ? x = i : x = R+1;
			while( x < n && s[x] == s[x-i] ) x++;
			z[i] = x-i; if( i < x ){ L = i; R = x-1; }
		}
		else z[i] = z[i-L];
	}
}


Output:
1
2
In function `_start':
undefined reference to `main'


Create a new paste based on this one


Comments: