void main() { int sz = 3; int eql = 0; int mov = 0; int **t = malloc(sz*(sizeof(int)+1)); for(i = 1; i <= sz; i++) t[i] = malloc(sz*sizeof(int)); int **b = malloc(sz*(sizeof(int)+1)); for(i = 1; i <= sz; i++) b[i] = malloc(sz*sizeof(int)); char roc; int n; initt(t, sz); initb(t, b, sz); while(eq(t, b, sz)) initb(t, b, sz); while(!eql) { printf("Target: \n"); printb(t, sz); printf("Board: \n"); printb(b, sz); printf("What to flip: "); scanf(" %c", &roc); scanf(" %d", &n); switch(roc) { case 'r': fliprow(b, sz, n); break; case 'c': flipcol(b, sz, n); break; default: perror("Please specify r or c and an number"); break; } printf("Moves Taken: %d\n", ++mov); if(eq(t, b, sz)) { printf("You win!\n"); eql = 1; } } }
int two_sat(int n){ initt(); for(int i=0;i<2*n;i+=2){ if(!mark[i]&&!mark[i^1]){ c=0; if(!dfs(i)){ while(c>0) mark[stk[--c]]=0; if(!dfs(i^1)) return 0; } } } return 1; }
int main(int argc, char **argv) { /* create window */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH); /* single buffering */ glutInitWindowSize(500, 500); glutCreateWindow("Subdivide"); /* set callbacks */ glutReshapeFunc(reshape1); glutDisplayFunc(displayt); glutMouseFunc(Mouse); glutMotionFunc(MouseMotion); glutKeyboardFunc(keyboardt); /* initialize GL */ initt(); glutMainLoop(); return(0); }