示例#1
0
文件: fastexpr.c 项目: nphuc/alg
int main(){
    char s[1000];
    register int i=0;
    int c;
    while((c=getchar_unlocked())!=EOF){
    	if(!isspace(c)){
    		s[i++]=c;
    	}
    }
    s[i]=0;
    stack st;
    prebuild(s,&st);
    stack out;
    //postfix(&st,&out);
    //long res=compute(&out);
    //printf("res1=%ld\n",res);
    long res2=solve(&st);
    printf("%ld",res2);
    return 0;
}
示例#2
0
文件: check-symbols.c 项目: AmkG/Orb
int main(void) {
	Orb_init(0, 0);
	Orb_t x = Orb_symbol("hello");
	Orb_t y = Orb_symbol_cc("hello");
	assert(x == y);
	Orb_gc_trigger();
	Orb_t z = Orb_symbol_cc("goodbye");
	Orb_gc_trigger();
	Orb_t w = Orb_symbol("goodbye");
	assert(z == w);
	assert(x != z);

	Orb_t xw = Orb_deref_cc(x, "write");
	Orb_t zw = Orb_deref_cc(z, "write");
	assert(zw == xw);

	xw = Orb_ref_cc(x, "write");
	zw = Orb_ref_cc(z, "write");
	assert(xw != zw);

	struct stringbuilder sb;
	prebuild(&sb);

	Orb_t opro;
	Orb_BUILDER {
		Orb_B_PARENT(Orb_t_from_cfunc(&pro));
		Orb_B_FIELD_cc("*sb", Orb_t_from_pointer(&sb));
	} opro = Orb_ENDBUILDER;

	Orb_t rv = Orb_call1(opro, x);
	assert(rv == Orb_NIL);
	assert(strcmp(sb.string, "hello") == 0);

	free(sb.string);

	return 0;
}