示例#1
0
/*FUNCTION*/
int c_equal(tpLspObject pLSP,
            LVAL p,
            LVAL q
  ){
/*noverbatim
CUT*/
  if( p == q ) return 1;
  if( gettype(p) != gettype(q) )return 0;
  switch( gettype(p) ){
    case NTYPE_CON:
      return equal(car(p),car(q)) && equal(cdr(p),cdr(q));
    case NTYPE_FLO:
      return getfloat(p)==getfloat(q);
    case NTYPE_INT:
      return getint(p)==getint(q);
    case NTYPE_STR:
      return  getstring(p) == getstring(q) ||
                       !strcmp(getstring(p),getstring(q));
    case NTYPE_SYM:
      return getsymbol(p) == getsymbol(q) ||
                 !strcmp(getsymbol(p),getsymbol(q));
    case NTYPE_CHR:
      return getchr(p) == getchr(q);
    default:
      return 0;
      break;
    }
  }
示例#2
0
文件: graph.c 项目: andreiw/polaris
void
readin(void)
{
	int t;
	struct val *temp;

	if(absf==1) {
		if(xd.xlbf)
			absbot = xd.xlb;
		else if(xd.xf==log10)
			absbot = 1;
	}
	for(;;) {
		temp = (struct val *)realloc((char*)xx,
			(unsigned)(n+1)*sizeof(struct val));
		if(temp==0)
			return;
		xx = temp;
		if(absf)
			xx[n].xv = n*dx + absbot;
		else
			if(!getfloat(&xx[n].xv))
				return;
		if(!getfloat(&xx[n].yv))
			return;
		xx[n].lblptr = -1;
		t = getstring();
		if(t>0)
			xx[n].lblptr = copystring(t);
		n++;
		if(t<0)
			return;
	}
}
示例#3
0
NODE *lsetactivearea(NODE *arg)
   {
   NODE *args;
   NODE *xlow;
   NODE *ylow;
   NODE *xhigh;
   NODE *yhigh;
   char szWinLocStr[WININISIZ];

   args = vector_4_arg(arg);

   // better be a list

   if (NOT_THROWING)
      {

      // apply all args that are given

      xlow  = car(args);
      ylow  = car(cdr(args));
      xhigh = car(cdr(cdr(args)));
      yhigh = car(cdr(cdr(cdr(args))));

      PrinterAreaXLow  = ((nodetype(xlow)  == FLOAT) ? getfloat(xlow)  : (FLONUM) getint(xlow));
      PrinterAreaYLow  = ((nodetype(ylow)  == FLOAT) ? getfloat(ylow)  : (FLONUM) getint(ylow));
      PrinterAreaXHigh = ((nodetype(xhigh) == FLOAT) ? getfloat(xhigh) : (FLONUM) getint(xhigh));
      PrinterAreaYHigh = ((nodetype(yhigh) == FLOAT) ? getfloat(yhigh) : (FLONUM) getint(yhigh));

      if ((PrinterAreaXLow >= PrinterAreaXHigh) || (PrinterAreaYLow >= PrinterAreaYHigh))
			{
			MainWindowx->CommandWindow->MessageBox("Bad argument", "Active Area");
			err_logo(STOP_ERROR, NIL);
			return (UNBOUND);
			}

      sprintf(szWinLocStr, "%d", PrinterAreaXLow);
      WritePrivateProfileString("Printer", "XLow", szWinLocStr, "LOGO.INI");
      sprintf(szWinLocStr, "%d", PrinterAreaXHigh);
      WritePrivateProfileString("Printer", "XHigh", szWinLocStr, "LOGO.INI");
      sprintf(szWinLocStr, "%d", PrinterAreaYLow);
      WritePrivateProfileString("Printer", "YLow", szWinLocStr, "LOGO.INI");
      sprintf(szWinLocStr, "%d", PrinterAreaYHigh);
      WritePrivateProfileString("Printer", "YHigh", szWinLocStr, "LOGO.INI");

      if (
            (PrinterAreaXLow  == -BitMapWidth  / 2) &&
            (PrinterAreaXHigh == +BitMapWidth  / 2) &&
            (PrinterAreaYLow  == -BitMapHeight / 2) &&
            (PrinterAreaYHigh == +BitMapHeight / 2)) PrinterCustomFlag = 0; else PrinterCustomFlag = 1;
      }

   return (UNBOUND);
   }
示例#4
0
文件: 5.02.c 项目: liudongmiao/tcpl
int main()
{
	double f;
	getfloat(&f);
	printf("f=%f\n", f);
	return 0;
}
示例#5
0
文件: 5-2.c 项目: afeefebrahim/k-r
int main (void)
{
    float array[SIZE];
    int n, r,i;
    for( i = 0; i < SIZE; i++)
    {
        array[i] = 0;
        //printf("array[%d] = %d\n", i, array[i]);
    }
    while(n < SIZE)
    {
        if ((r =getfloat(&array[n])) == 0) {
	        getch();
		n += 1;
        }
        if (r == EOF) {
	    array[n++] = '\0';	
            continue;
		
        }
    }
    for( i = 0; i < SIZE; i++)
   	 printf("array[%d] = %f\n", i, array[i]);

    return 0;
}
示例#6
0
ctl_parameter_t get_ctl_parameter(const char ***_argv, int *_argc, int start_argc, const char *type, int count)
{
	ctl_parameter_t new_ctl_param;
	const char **argv = *_argv;
	int argc = *_argc;
    
	memset(&new_ctl_param, 0, sizeof(new_ctl_param));
    
	argv++;
	argc--;
    
	new_ctl_param.name = argv[0];
    
	argv++;
	argc--;
    
	new_ctl_param.count = count;
	for (int i = 0; i < new_ctl_param.count; i++)
	{
		new_ctl_param.value[i] = getfloat(argv[0], "value %d of %s parameter %s (absolute parameter %d)", i + 1, type, new_ctl_param.name, start_argc - argc);
		argc--;
		argv++;
	}
    
	*_argv = argv - 1;
	*_argc = argc + 1;
    
	return new_ctl_param;
}
示例#7
0
/*FUNCTION*/
int c_flatc(tpLspObject pLSP,
            LVAL p
  ){
/*noverbatim
CUT*/
  int j;
  LVAL fp;

  if( null(p) )return 3;
  switch( gettype(p) ){
    case NTYPE_CON:
      for( fp = p , j = 1/*(*/ ; fp ; fp = cdr(fp) )
      j+= flatc(car(fp))+1/*space*/;
      return p ? j : 1+j; /*) was calculated as a space. (Not always.) */
    case NTYPE_FLO:
      sprintf(BUFFER,"%lf",getfloat(p));
      break;
    case NTYPE_INT:
      sprintf(BUFFER,"%ld",getint(p));
      break;
    case NTYPE_STR:
      sprintf(BUFFER,"\"%s\"",getstring(p));
      break;
    case NTYPE_SYM:
      sprintf(BUFFER,"%s",getsymbol(p));
      break;
    case NTYPE_CHR:
      sprintf(BUFFER,"#\\%c",getchr(p));
      break;
    default:
      return 0;
      }
  return strlen(BUFFER);
  }
示例#8
0
文件: 5_2.c 项目: jinto-thomas/knr
main()
{
	float n;
	getfloat(&n);
	printf("%f\n",n);
	return 0;
}
示例#9
0
main()
{
	float array[SIZE], getfloat(float *);
	int n,i;
	for (n = 0; n < SIZE && getfloat(&array[n]) != EOF; n++)
		printf("a is =%f\n",array[n]);
}
示例#10
0
static void
pushvalue(lua_State *L, const void *v, int type, const struct document * doc) {
	switch (type) {
	case VALUE_NIL:
		lua_pushnil(L);
		break;
	case VALUE_INTEGER:
		lua_pushinteger(L, (int32_t)getuint32(v));
		break;
	case VALUE_REAL:
		lua_pushnumber(L, getfloat(v));
		break;
	case VALUE_BOOLEAN:
		lua_pushboolean(L, getuint32(v));
		break;
	case VALUE_TABLE:
		create_proxy(L, doc, getuint32(v));
		break;
	case VALUE_STRING:
		lua_pushstring(L,  (const char *)doc + doc->strtbl + getuint32(v));
		break;
	default:
		luaL_error(L, "Invalid type %d at %p", type, v);
	}
}
int main( void ){

	int index;
	float array[128];
	int flag;
	
	index = 0;
	while(index < 128){	
		// get float
		flag = getfloat(array+index);

		if(flag == EOF){
			break;
		}else if(flag == NUMBER){	
			// show the result
			printf("the data in array of index %d is %f.\n", index, array[index]);	
			index++;
		}else if(flag == INVALID){
			printf("ignore a character from the stream.\n");
		}

	}

	return 0;
}
void Shape_CreateCircle(avm *vm)
{
    word wr;
    sfColor Col;
    Col.r = getint(vm, 3);
    Col.g = getint(vm, 4);
    Col.b = getint(vm, 5);
    Col.a = getint(vm, 6);
    sfColor OutlineCol;
    OutlineCol.r = getint(vm, 8);
    OutlineCol.g = getint(vm, 9);
    OutlineCol.b = getint(vm, 10);
    OutlineCol.a = getint(vm, 11);
    seti(&wr, sfShape_CreateCircle(getfloat(vm, 0), getfloat(vm, 1), getfloat(vm, 2), Col, getfloat(vm, 7), OutlineCol));
    returnv(vm, &wr);
}
示例#13
0
//driver function
int main(void){
	float num;

	num = getfloat();
	printf("The Number you entered:\t%f\n",num);

	return 0;
}
示例#14
0
int main(int arg, char *argv[])
{
    double d;
    if(getfloat(&d))
    {
        printf("%f\n", d);
    }
    return 0;
}
示例#15
0
文件: 5-2.c 项目: weezybusy/KnR2
int main(void)
{
        float f;

        if (getfloat(&f))
                printf("%g\n", f);

        return 0;
}
示例#16
0
文件: input2.c 项目: sdteffen/epanetl
double  hour(char *time, char *units)
/*
**---------------------------------------------------------
**  Input:   *time  = string containing a time value
**           *units = string containing time units
**  Output:  returns numerical value of time in hours,
**           or -1 if an error occurs
**  Purpose: converts time from units to hours
**---------------------------------------------------------
*/
{
   int    n;
   double  y[3];
   char   *s;

/* Separate clock time into hrs, min, sec. */
   for (n=0; n<3; n++) y[n] = 0.0;
   n = 0;
   s = strtok(time,":");
   while (s != NULL && n <= 3)
   {
      if (!getfloat(s,&y[n]))  return(-1.0);
      s = strtok(NULL,":");
      n++;
   }

/* If decimal time with units attached then convert to hours. */
    if (n == 1)
    {
      /*if (units[0] == '\0')       return(y[0]);*/
      if (strlen(units) == 0)     return(y[0]);
      if (match(units,w_SECONDS)) return(y[0]/3600.0);
      if (match(units,w_MINUTES)) return(y[0]/60.0);
      if (match(units,w_HOURS))   return(y[0]);
      if (match(units,w_DAYS))    return(y[0]*24.0);
    }

/* Convert hh:mm:ss format to decimal hours */
    if (n > 1) y[0] = y[0] + y[1]/60.0 + y[2]/3600.0;

/* If am/pm attached then adjust hour accordingly */
/* (12 am is midnight, 12 pm is noon) */
    if (units[0] == '\0')  return(y[0]);
    if (match(units,w_AM))
    {
       if (y[0] >= 13.0) return(-1.0);
       if (y[0] >= 12.0) return(y[0]-12.0);
       else return(y[0]);
    }
    if (match(units,w_PM))
    {
       if (y[0] >= 13.0) return(-1.0);
       if (y[0] >= 12.0) return(y[0]);
       else return(y[0]+12.0);
    }
    return(-1.0);
}                        /* end of hour */
示例#17
0
文件: usegetfloat.c 项目: ddakhane/c
/* 测试 getint() 函数 */
int main(void)
{
	int n;
	float array[SIZE] = {0.0};

	for (n = 0; n < SIZE && getfloat(&array[n]) != EOF; ++n)
		printf("array[%d] = %g\n", n , array[n]);
	return 0;
}
示例#18
0
文件: e02.c 项目: kokosabu/exercises
int main()
{
    double d;

    while (getfloat(&d) != EOF)
        printf("%f\n", d);

    return 0;
}
示例#19
0
int main(){
    
    double nextFloat;
    
    while( getfloat(&nextFloat) ){
        printf("Next float: %f\n",nextFloat);
    }
    
    return 0;
}
示例#20
0
int main()
{
    float *fn;
    int i;
            
    while(*fn != EOF) {
        i = getfloat(fn);
        printf("%g\n",*fn);
    }
}
示例#21
0
 void run()
 {
     if(type == ACTION) { if(val.s) execute(val.s); }
     else if(id) switch(id->type)
     {
         case ID_VAR: setvarchecked(id, getint()); break;
         case ID_FVAR: setfvarchecked(id, getfloat()); break;
         case ID_SVAR: setsvarchecked(id, getstring()); break;
         case ID_ALIAS: alias(id->name, getstring()); break;
     }
 }
示例#22
0
文件: main.c 项目: AlonsoCerpa/IPOO
int main()
{
    float array[SIZE];
    int getfloat(float *);

    for (n = 0; n < SIZE && getfloat(&array[n]) != EOF; n++)
        ;
    for (n = 0; n < SIZE; n++)
        printf("%f ", array[n]);
    return 0;
}
示例#23
0
文件: fp_2.c 项目: certik/nwcc
int
main() {
	float		f;
	double		d;
	long double	ld;

	while ((f = getfloat()) != 0.0f) {
		printf("%f %f %Lf\n", f, getdouble(), getlongdouble());
	}
	return 0;
}
示例#24
0
文件: 5-2_getfloat.c 项目: leilux/lou
main()
{
	int n, getfloat(float *);
	float array[SIZE]; 

	for (n = 0; n < SIZE && getfloat(&array[n]) != EOF; n++)
		;
	for(; n > 0; n--)
		printf("%g, ", array[n-1]);
	printf("\n");
}
示例#25
0
文件: rules.c 项目: CitiLogics/EPANET
int  newpriority()
/*
**---------------------------------------------------
**    Adds priority rating to current rule
**---------------------------------------------------
*/
{
    double x;
    if (!getfloat(Tok[1],&x)) return(202);
    Rule[Nrules].priority = x;
    return(0);
}
示例#26
0
main()
{
        int i;
	float array[BSIZE];
	int getfloat(float *pn);
	int val;
    	
	for(i = 0; i < BSIZE && (val = getfloat(&array[i])) != EOF; i++)
           printf("array[%d] = %f, \tvalue returned:  (%s)\n", i, array[i], 			val != 0 ? "number" : "not a number");

	return 0;
}
示例#27
0
int main()
{
    double f;
    int rc;
    int w1 = 8;

    while((rc = getfloat(&f)) != EOF && rc != 0)
    {
        printf("getfloat returned: %*i  and retrieved: %g\n", w1, rc, f);
    }
    return 0;
}
示例#28
0
文件: e02.c 项目: kokosabu/exercises
int getfloat(double *pn)
{
    double power;
    int c, sign;

    while (isspace(c = getch()))
        ;
    if (!isdigit(c) && c != EOF && c != '+' && c != '-' && c != '.') {
        ungetch(c);
        return 0;
    }
    sign = (c == '-') ? -1 : 1;
    if (c == '+' || c == '-')
        c = getch();
    if (!isdigit(c) && c != '.' && c != EOF) {
        ungetch(c);
        return getfloat(pn);
    }
    for (*pn = 0.0; isdigit(c); c = getch())
        *pn = 10.0 * *pn + (c - '0');

    if (c == '.') {
        c = getch();
        if (!isdigit(c) && c != EOF) {
            ungetch(c);
            return getfloat(pn);
        }
    }

    for (power = 1.0; isdigit(c); c = getch()) {
        *pn = 10.0 * *pn + (c - '0');
        power *= 10.0;
    }
    *pn *= sign / power;

    if (c != EOF)
        ungetch(c);
    return c;
}
示例#29
0
void e_5_2(void)
{
	int i;
	float f[20] = {0.0};

	printf("e_5_2:");
	for(i = 0;i < 20;++i){
		getfloat(&f[i]);
		printf("f is %f\n", f[i]);
	}

	return;
}
示例#30
0
文件: tp4_14a.c 项目: jpmrno/PI
int
main (void)
{
	float x, y, z;
	x= getfloat("Ingrese un número real :");
	putchar('\n');

	y = f1(x);
	z = f2(x);

	printf("El doble absoluto de %g es %g\n",x, y);
	printf("El triple absoluto de %g es %g\n",x , z);
	return 0;
}