Exemplo n.º 1
0
Arquivo: ex202.c Projeto: newnix/Forge
int main()
{
	/* declaring main vars */
	char instring[slength], outstring[slength]; /* input string and output string */

	get_line2(instring, slength); /* get a line of input from the user */
	copy(instring, outstring); /* copy the string to burn some cpu cycles */
	printf("%s",outstring); /* print the string */

	return 0; /* because I don't catch exceptions either */
}
Exemplo n.º 2
0
void ocr2(pix *b,int cs){
  int x1,y1,x2,y2,l,i,j,xa[MAXL],ya[MAXL],xb[MAXL],yb[MAXL],ll[MAXL];
  for(i=0;i<MAXL;i++)xa[i]=ya[i]=xb[i]=yb[i]=ll[i]=0;
  for(x1=0;x1<b->x;x1++)		// very slowly, but simple to program
  for(y1=0;y1<b->y;y1++)         // brute force
  for(x2=0;x2<b->x;x2++)
  for(y2=y1+1;y2<b->y;y2++)
  {
    if( get_line2(x1,y1,x2,y2,b,cs,100)>99 )
    {  // line ???
      l=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);  // len
      for(i=0;i<MAXL;i++)
      {  // remove similar lines (same middle point) IMPROVE IT !!!!!! ???
        if(
            abs(x1+x2-xa[i]-xb[i])<1+b->x/2
         && abs(y1+y2-ya[i]-yb[i])<1+b->y/2
         && abs(y1-ya[i])<1+b->y/4
         && abs(x1-xa[i])<1+b->x/4
          )
        {
          if( l>ll[i] )
          {
            for(j=i;j<MAXL-1;j++)
            {  // shift table
              xa[j]=xa[j+1];ya[j]=ya[j+1];
              xb[j]=xb[j+1];yb[j]=yb[j+1];ll[j]=ll[j+1];
            }
            ll[MAXL-1]=0;
          }
          else break; // forget it if shorter
        }
        if( l>ll[i] ){ // insert if larger
          for(j=MAXL-1;j>i;j--){  // shift table
            xa[j]=xa[j-1];ya[j]=ya[j-1];
            xb[j]=xb[j-1];yb[j]=yb[j-1];ll[j]=ll[j-1];
          }
          xa[i]=x1;ya[i]=y1;xb[i]=x2;yb[i]=y2;ll[i]=l;
          break;
        }
      }
    }
  }
  for(i=0;i<MAXL;i++){
    printf(" %2d %2d %2d %2d %3d\n",xa[i],ya[i],xb[i],yb[i],ll[i]);
  }  
}