void test_functions() { double x, y; te_variable lookup[] = {{"x", &x}, {"y", &y}}; int err; te_expr *expr; for (x = -5; x < 5; x += .2) { cross_check("abs x", fabs(x)); cross_check("acos x", acos(x)); cross_check("asin x", asin(x)); cross_check("atan x", atan(x)); cross_check("ceil x", ceil(x)); cross_check("cos x", cos(x)); cross_check("cosh x", cosh(x)); cross_check("exp x", exp(x)); cross_check("floor x", floor(x)); cross_check("ln x", log(x)); cross_check("log10 x", log10(x)); cross_check("sin x", sin(x)); cross_check("sinh x", sinh(x)); cross_check("sqrt x", sqrt(x)); cross_check("tan x", tan(x)); cross_check("tanh x", tanh(x)); for (y = -2; y < 2; y += .2) { if (fabs(x) < 0.01) break; cross_check("atan2(x,y)", atan2(x, y)); cross_check("pow(x,y)", pow(x, y)); } } }
int input() { int x=0,y=0,number=0,result=0; char num[3]=" "; char opt[3]=" "; char temp=' '; opt[2]='\n'; printf("\n x y number : "); result=scanf("%c",&opt[0]); if(opt[0]=='s') return SUBMIT; else if(opt[0]=='q') return QUIT; x=atoi(opt); result+=scanf(" %d",&y); result+=scanf(" %c",&temp); clear(); opt[0]=temp; if(result!=3) { printf("invalid input\n"); return -1; } if(opt[0]=='d') number=-1; else number=atoi(opt); if(x>=1 && x<=9 && y>=1 && y<=9) { if( fixed[x-1][y-1]!=0 && number!=0) { if(number>=1 && number<=9) { if(cross_check(x-1,y-1,number)==alreadyis || square_check(x-1,y-1,number)==alreadyis ) { printf("your input was %d, and %d is already exist.\n",number,number); return alreadyis; } usersol[x-1][y-1]=number; sprintf(num,"%d",number); display[x-1][y-1]=num[0]; return 0; } else if(number==-1) { usersol[x-1][y-1]=0; display[x-1][y-1]=' '; return 0; } } else { printf("your input was %d, %d, %d . you can't change original setting\n",x,y,number); return -1; } } else { printf("your input was %c %d %c, please check your input\n",opt[0],y,temp); return -1; } }