Example #1
0
int Fcopyto(FILE * const fdst, FILE * const fsrc, const fpos_t * const pos)
{	fpos_t cpos;
	dword dw_cpos, dw_topos;

	DBG_ENTER("Fcopyto", Suppl_supplio)

	assert(fdst);
	assert(fsrc);
	assert(pos);

	/* Because the (fpos_t) data type is a blackbox type completely,
		one would need to copy the stream character-by-character in
		order to ensure that the pos is reached.

		SUPPL assumes that there is a way to calculate the offset
		of data type (dword) from the (fpos_t) values, which is
		hidden into the Fpos2dword() function.
	*/
	if(FFgetpos(fsrc, cpos))			/* get current position */
		DBG_RETURN_I( 1)			/* general access error */

	Fpos2dword(cpos, dw_cpos);
	Fpos2dword(pos, dw_topos);

	if(longcmp1(dw_topos, dw_cpos) <= 0)
		DBG_RETURN_I( 0)	/* current position already behind end position */

	/* Amount of bytes to be copied */
	longsub(dw_topos, dw_cpos);

	DBG_RETURN_BI( Fcopyl(fdst, fsrc, dw_topos))
}
Example #2
0
int Longest(string s)
{
   int n = s.size(); 
    vector<vector<int> > longsub(n+1,  vector<int>(n+1)) ;
    int res = 0 ;
    string str = s;
    reverse(s.begin(), s.end());

    for(int i=1; i<n+1; i++)
           for(int j=1; j<n+1; j++)
               if(s[i-1] == str[j-1])
                   longsub[i][j] = longsub[i-1][j-1] +1;
               else 
                   longsub[i][j] = max(longsub[i][j-1], longsub[i-1][j]);

    return longsub[n][n];
}