Ejemplo n.º 1
0
void dostr(int len)
{

   if(len == n)
   {
      return ; 
   }
   anst ++;
   int k = len /2;
   for(int i = 1 ;i <= k ;i ++)
   {
      if(str[i] != str[len - i + 1])
		  anssum ++ ; 
   }
   dostr(len/2);
}
Ejemplo n.º 2
0
int main(){
     
	 clock_t en,be;
//	 be = clock();
	 freopen("DNA.in","r",stdin);
     freopen("DNA.out","w",stdout);
	 int t ;
	 scanf("%d",&t);
	 for(int i = 1;i <= t;i ++)
	 {
		anssum =  0 ; 
		anst = 0 ; 
	    scanf("%d",&n);
			scanf("%s",&str[1]);
		dostr(strlen(&str[1]));
		printf("%d %d\n",anst,anssum);
	 }
     en = clock();
//	 printf("%lf",(en -be)*1.0/CLOCKS_PER_SEC);
return 0 ;
}
Ejemplo n.º 3
0
static void
dopr(char *buffer, const char *format, va_list args)
{
   int                 ch;
   long                value;
   int                 longflag = 0;
   char               *strvalue;
   int                 ljust;
   int                 len;
   int                 zpad;
   int                 precision;
   int                 set_precision;
   double              dval;

   output = buffer;
   while ((ch = *format++))
     {
	switch (ch)
	  {
	  case '%':
	     ljust = len = zpad = 0;
	     precision = -1;
	     set_precision = 0;
	   nextch:
	     ch = *format++;
	     switch (ch)
	       {
	       case 0:
		  dostr("**end of format**");
		  return;
	       case '-':
		  ljust = 1;
		  goto nextch;
	       case '.':
		  set_precision = 1;
		  precision = 0;
		  goto nextch;
	       case '*':
		  len = va_arg(args, int);

		  goto nextch;
	       case '0':	/* set zero padding if len not set */
		  if (len == 0 && set_precision == 0)
		     zpad = '0';
	       case '1':
	       case '2':
	       case '3':
	       case '4':
	       case '5':
	       case '6':
	       case '7':
	       case '8':
	       case '9':
		  if (set_precision)
		    {
		       precision = precision * 10 + ch - '0';
		    }
		  else
		    {
		       len = len * 10 + ch - '0';
		    }
		  goto nextch;
	       case 'l':
		  longflag = 1;
		  goto nextch;
	       case 'u':
	       case 'U':
		  /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
		  if (longflag)
		    {
		       value = va_arg(args, long);
		    }
		  else
		    {
		       value = va_arg(args, int);
		    }
		  fmtnum(value, 10, 0, ljust, len, zpad, precision);
		  break;
	       case 'o':
	       case 'O':
		  /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
		  if (longflag)
		    {
		       value = va_arg(args, long);
		    }
		  else
		    {
		       value = va_arg(args, int);
		    }
		  fmtnum(value, 8, 0, ljust, len, zpad, precision);
		  break;
	       case 'd':
	       case 'i':
	       case 'D':
		  if (longflag)
		    {
		       value = va_arg(args, long);
		    }
		  else
		    {
		       value = va_arg(args, int);
		    }
		  fmtnum(value, 10, 1, ljust, len, zpad, precision);
		  break;
	       case 'x':
		  if (longflag)
		    {
		       value = va_arg(args, long);
		    }
		  else
		    {
Ejemplo n.º 4
0
static void
dopr(char *buffer, const char *format, va_list args)
{
	int			ch;
	long_long	value;
	double		fvalue;
	int			longlongflag = 0;
	int			longflag = 0;
	int			pointflag = 0;
	int			maxwidth = 0;
	char	   *strvalue;
	int			ljust;
	int			len;
	int			zpad;

	output = buffer;
	while ((ch = *format++))
	{
		switch (ch)
		{
			case '%':
				ljust = len = zpad = maxwidth = 0;
				longflag = longlongflag = pointflag = 0;
		nextch:
				ch = *format++;
				switch (ch)
				{
					case 0:
						dostr("**end of format**", 0);
						*output = '\0';
						return;
					case '-':
						ljust = 1;
						goto nextch;
					case '0':	/* set zero padding if len not set */
						if (len == 0 && !pointflag)
							zpad = '0';
					case '1':
					case '2':
					case '3':
					case '4':
					case '5':
					case '6':
					case '7':
					case '8':
					case '9':
						if (pointflag)
							maxwidth = maxwidth * 10 + ch - '0';
						else
							len = len * 10 + ch - '0';
						goto nextch;
					case '*':
						if (pointflag)
							maxwidth = va_arg(args, int);
						else
							len = va_arg(args, int);
						goto nextch;
					case '.':
						pointflag = 1;
						goto nextch;
					case 'l':
						if (longflag)
							longlongflag = 1;
						else
							longflag = 1;
						goto nextch;
					case 'u':
					case 'U':
						/* fmtnum(value,base,dosign,ljust,len,zpad) */
						if (longflag)
						{
							if (longlongflag)
								value = va_arg(args, ulong_long);
							else
								value = va_arg(args, unsigned long);
						}
						else
							value = va_arg(args, unsigned int);
						fmtnum(value, 10, 0, ljust, len, zpad);
						break;
					case 'o':
					case 'O':
						/* fmtnum(value,base,dosign,ljust,len,zpad) */
						if (longflag)
						{
							if (longlongflag)
								value = va_arg(args, ulong_long);
							else
								value = va_arg(args, unsigned long);
						}
						else
							value = va_arg(args, unsigned int);
						fmtnum(value, 8, 0, ljust, len, zpad);
						break;
					case 'd':
					case 'i':
					case 'D':
						if (longflag)
						{
							if (longlongflag)
								value = va_arg(args, long_long);
							else
								value = va_arg(args, long);
						}
						else
Ejemplo n.º 5
0
static void dopr( char *buffer, const char *format, va_list args )
{
	int ch;
	union value value;
	int longflag = 0;
	int quadflag = 0;
	char *strvalue;
	int ljust;
	int len;
	int zpad;
	int precision;
	int set_precision;
	double dval;
	int err = errno;
	int plp_base = 0;
	int signed_val = 0;

	output = buffer;
	while( (ch = *format++) ){
		switch( ch ){
		case '%':
			longflag = quadflag =
			ljust = len = zpad = plp_base = signed_val = 0;
			precision = -1; set_precision = 0;
		nextch:
			ch = *format++;
			switch( ch ){
			case 0:
				dostr( "**end of format**" );
				return;
			case '-': ljust = 1; goto nextch;
			case '.': set_precision = 1; precision = 0; goto nextch;
			case '*': len = va_arg( args, int ); goto nextch;
			case '0': /* set zero padding if len not set */
				if(len==0 && set_precision == 0 ) zpad = '0';
				/* FALLTHROUGH */
			case '1': /* FALLTHROUGH */
			case '2': /* FALLTHROUGH */
			case '3': /* FALLTHROUGH */
			case '4': /* FALLTHROUGH */
			case '5': /* FALLTHROUGH */
			case '6': /* FALLTHROUGH */
			case '7': /* FALLTHROUGH */
			case '8': /* FALLTHROUGH */
			case '9':
				if( set_precision ){
					precision = precision*10 + ch - '0';
				} else {
					len = len*10 + ch - '0';
				}
				goto nextch;
			case 'l': ++longflag; goto nextch;
			case 'q': quadflag = 1; goto nextch;
			case 'u': case 'U':
				if( plp_base == 0 ){ plp_base = 10; signed_val = 0; }
				/* FALLTHROUGH */
			case 'o': case 'O':
				if( plp_base == 0 ){ plp_base = 8; signed_val = 0; }
				/* FALLTHROUGH */
			case 'd': case 'D':
				if( plp_base == 0 ){ plp_base = 10; signed_val = 1; }
				/* FALLTHROUGH */
			case 'x':
				if( plp_base == 0 ){ plp_base = 16; signed_val = 0; }
				/* FALLTHROUGH */
			case 'X':
				if( plp_base == 0 ){ plp_base = -16; signed_val = 0; }
				if( quadflag || longflag > 1 ){
#if defined(HAVE_LONG_LONG)
					if( signed_val ){
					value.value = va_arg( args, long long );
					} else {
					value.value = va_arg( args, unsigned long long );
					}
#else
					if( signed_val ){
					value.value = va_arg( args, long );
					} else {
					value.value = va_arg( args, unsigned long );
					}
#endif
				} else if( longflag ){
					if( signed_val ){
						value.value = va_arg( args, long );
					} else {
						value.value = va_arg( args, unsigned long );
					}
				} else {