int main (int argc, char** argv) { //Seed random srand(time(NULL)); int random = rand() % 20 + 1; printf ("Test Buy Card.\n"); //Test function 5 times for(int i = 0; i < 5; i++) { functionTest(random); } return 0; }
BOOL CBoxProxyView::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加专用代码和/或调用基类 if (WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST) { //判断是否按下键盘Enter键 if(pMsg->wParam=='q') { //Do anything what you want to showExtend=!showExtend; CPaintDC dc(this); OnDraw(&dc); } if(pMsg->wParam=='w') { //Do anything what you want to showOrig=!showOrig; CPaintDC dc(this); OnDraw(&dc); } if(pMsg->wParam=='s') { //Do anything what you want to cI.setPara(configPara); functionTest(); GetDepthMapFromView(); testMode=true; testBoxExtend(); if (conGraph!=NULL) delete conGraph; conGraph=new ContactGraph(boxes,downDir,type,configPara); GraphCreated=true; CPaintDC dc(this); OnDraw(&dc); } if(pMsg->wParam=='d') { //Do anything what you want to GraphFinished=false; while (1) { bool go=conGraph->IterateOneStep(); bool result=conGraph->getResult(); for (int i=0;i<conGraph->getNodeNum()-1;i++) { for (int j = i+1; j < conGraph->getNodeNum(); j++) { //printf("%d ",conGraph->GetIterator(i,j)); } } //printf("\n"); if (result) { //CPaintDC dc(this); //OnDraw(&dc); double err=conGraph->getError(); //printf("%f\n",err); if (err>0&&err<configPara.error_threshold) { CString c; c.Format("%.10f",conGraph->getError()); CPaintDC dc(this); OnDraw(&dc); MessageBox(c); break; } } if (!go) { MessageBox("循环结束!"); break; } } CPaintDC dc(this); OnDraw(&dc); } if(pMsg->wParam=='f') { while (1) { bool go=conGraph->IterateOneStep(); bool result=conGraph->getResult(); //printf("\n"); if (result) { CPaintDC dc(this); OnDraw(&dc); double err=conGraph->getError(); printf("%f\n",err); if (err>0) { CString c; c.Format("%.10f",conGraph->getError()); CPaintDC dc(this); OnDraw(&dc); MessageBox(c); } break; } if (!go) { MessageBox("循环结束!"); break; } } CPaintDC dc(this); OnDraw(&dc); } if(pMsg->wParam=='e') { //Do anything what you want to while (1) { bool go=conGraph->IterateOneStep(); if (!go) { GraphFinished=true; break; } } CPaintDC dc(this); OnDraw(&dc); MessageBox("循环结束!"); } } return CView::PreTranslateMessage(pMsg); }
int main(){ implementation imp; functionTest(imp); }