/** * Actions execute method. */ DWORD ExecuteAdtDeleteObjectAction(IN AdtActionTP action) { DWORD dwError = 0; AppContextTP appContext = (AppContextTP) ((AdtActionBaseTP) action)->opaque; PrintStderr(appContext, LogLevelVerbose, "%s: Calling delete object operation ...\n", appContext->actionName); dwError = DeleteADObject(appContext, action->deleteObject.dn, action->deleteObject.isDeleteMembers); ADT_BAIL_ON_ERROR_NP(dwError); PrintStderr(appContext, LogLevelVerbose, "%s: Calling delete object operation - done\n", appContext->actionName); if(appContext->gopts.isPrintDN) { PrintResult(appContext, LogLevelNone, "%s\n", action->deleteObject.dn); } else { PrintResult(appContext, LogLevelNone, "Object %s has been deleted.\n", action->deleteObject.dn); } cleanup: return dwError; error: goto cleanup; }
int ParserManager::PrintResult() { if( code == ttmath::err_ok ) { #ifndef TTCALC_PORTABLE switch( precision ) { case 0: return PrintResult(parser1); case 1: return PrintResult(parser2); default: return PrintResult(parser3); } #else return PrintResult(parser1); #endif } return 0; }
// Main function that executes the blackjack game with a new player void CBlackJack::StartGameWithNewPlayer() { bool playAgain = true; PrintHandBeginsMessage(Player.GetName(), Player.GetChips()); while(playAgain) { // Ask player for a wager. It returns true if valid wager is returned if(GetSetPlayerWager()) { // Hit the player twice Hit(Player); Hit(Player); DEBUG_LOG (4, "Hit Player twice"); if(Player.IsBlackjack()) PrintResult(PLAYER_BLACKJACK, Player.GetName(), 0); // Hit dealer twice Hit(Dealer); Hit(Dealer); DEBUG_LOG (4, "Hit Dealer twice"); if(Dealer.IsBlackjack()) PrintResult(DEALER_BLACKJACK, Dealer.GetName(), 0); // If dealer or player got blackjack or busted, then game can end here. // Else, continue playing if(!Player.IsBlackjack() && !Player.IsBusted() && !Dealer.IsBlackjack() && !Dealer.IsBusted()) { // Display scores Player.PrintScore(); Dealer.PrintScore(); // Give playing options to player and play PlayerOptionsAndPlay(); // Unless player is busted, continue hitting the dealer if(!Player.IsBusted()) DealerOptionsAndPlay(); } // At the end, check for winner, and calculate payout CheckWinnerCalculatePayout(); } // Ask player for another game playAgain = EndOption(); } // end while playAgain // Add player's score to high scores DEBUG_LOG(1, "Remaining chips " << Player.GetChips()); HighScoreHandler.AddNewScore(Player.GetName(), Player.GetChips()); // Reset remaining chips with player Player.Reset(); PrintHandQuitMessage(); }
void main(){ char data; snake s1; feed f1; int SnakeSpeed=45; int SnakeSpeedArray[]={100,100,95,80,75,60,50,40,30,20,10,5,1}; int LimitTimeArray[] ={60000 ,60000 ,55000,50000,45000,40000,35000,30000,25000,20000,15000,10000,5000}; int NTailArray[] ={5 ,7 ,10,15,30,35,40,45,50,57,63,67,70}; display(); do{ inform(s1,f1,startTime,LimitTimeArray[step],SnakeSpeedArray[step],NTailArray[step],step); //¹öÀü1 inform(s1,f1,startTime,10000000000000,SnakeSpeed,99,0); if(f1.eatten){ f1.pos=f1.makeFeed(s1); f1.eatten=false; } f1.drawFeed(); if(f1.isiteatten(s1)&&s1.ntail<99){ s1.ntail++; } if(!s1.Crash()){ PrintResult(LimitTimeArray[step],s1.ntail,SnakeSpeedArray[step],0); //¹öÀü1 break; } if(s1.ntail>=NTailArray[step]){ PrintResult(LimitTimeArray[step],s1.ntail,SnakeSpeedArray[step],1); s1.head.X=38; s1.head.Y=11; s1.ntail=1; startTime = GetTickCount(); s1.GoAheadCOORD(s1.ntail); if(step<12) step++; display(); } data = getch(); if(kbhit()) continue; ungetch(data); s1.move(data); Sleep(SnakeSpeedArray[step]); }while(1); }
static int AmbaIQPage_set_params_fb () { if (receive_buffer->status == STATUS_SUCCESS) { PrintResult(STATUS_SUCCESS); } else { PrintResult(STATUS_FAILURE); } return 0; }
void Test::TestCase::Run(void) { Setup(); string output = ""; if (testRun_ != NULL) result_ = testRun_(output, GetFormattedCaseTitle()); PrintResult(GetFormattedCaseTitle() + (result_ ? "PASSED!" : "FAILED!"), result_); PrintResult(output, result_); Cleanup(); }
// N^2 Totally useless when N gets bigger void FindTwoSumK(int *array, int len, int K) { if (len < 2) return; // array[0] --- smallest number // array[len-1] --- biggest number if (array[0] >= K) { if (array[0] > 0) return; for (int i = 0; i < len && array[i] <= 0; ++i) { for (int j = i + 1; j < len && array[j] <= 0; ++j) { if (array[i] + array[j] == K) { PrintResult("Find case: %5d %5d %5d\n", -K, array[i], array[j]); } } } } else if (array[len-1] <= K) { if (array[len-1] < 0) return; for (int i = len-1; i >= 0 && array[i] >= 0; --i) { for (int j = i - 1; j >= 0 && array[j] >= 0; --j) { if (array[i] + array[j] == K) { PrintResult("Find case: %5d %5d %5d\n", -K, array[i], array[j]); } } } } else { for (int i = 0; i < len; ++i) { for (int j = i + 1; j < len; ++j) { if (array[i] + array[j] == K) { PrintResult("Find case: %5d %5d %5d\n", -K, array[i], array[j]); } } } } }
void PrintResult(struct Node* startnode, char* codestring, int level) { if ((startnode -> leftnode) != NULL) { codestring[level] = '0'; PrintResult(startnode -> leftnode, codestring, level+1); codestring[level]= '1'; PrintResult(startnode -> rightnode, codestring, level+1); } else { printf("%.2f => ", startnode -> prob); codestring[level] = '\0'; printf("%s\n", codestring); } }
void main() { vector< vector< int > > vvScreen(4, vector< int >(4, 0)); vvScreen[1][1] = 1; vvScreen[1][2] = 1; vvScreen[2][1] = 1; vvScreen[2][2] = 1; PrintResult(vvScreen); PaintFill(vvScreen, 1, 1, 1, 2); PrintResult(vvScreen); }
TStack::TStack(const std::string fileName) { fin.open(fileName, std::ios::binary|std::ios::in); if (!fin.is_open()) { return; } fin.seekg(0, fin.end); size_t len = fin.tellg(); fin.seekg(0, fin.beg); Buffer.resize(len); fin.read((char*)(&Buffer[0]), len); while (Allocator()) { } stdFuncMap.insert(std::make_pair("+", &plus)); stdFuncMap.insert(std::make_pair("-", &minus)); stdFuncMap.insert(std::make_pair("/", &division)); stdFuncMap.insert(std::make_pair("*", &mult)); stdFuncMap.insert(std::make_pair("cons", &cons)); stdFuncMap.insert(std::make_pair("append", &append)); stdFuncMap.insert(std::make_pair("list", &list)); stdFuncMap.insert(std::make_pair("=", &equally)); stdFuncMap.insert(std::make_pair("define", &defineFun)); DoCode(); PrintResult(); }
//IsError = 0 is false; int main() { int CaseCount = 0; scanf("%d",&CaseCount); fflush(stdin); IsError = 0; CaseLoop(CaseCount,0); if (IsError == 1) { //TODO NOTHING. } else { if(CaseCount == 0){ printf ("\n No case. \n\n"); } else{ printf ("\n Show Output \n\n"); } PrintResult(ResultArray,CaseCount,0); } return 0; }
void MyGS1::SearchStableMatch(int index, PARTNER *boys, PARTNER *girls) //递归的方法 { if(index == UNIT_COUNT) //递归到了某个分支的终点,此时匹配结果一定是完全匹配,但不一定是稳定匹配 { totalMatch++; if(IsStableMatch(boys, girls)) //是否存在不稳定因素,如果没有,就是稳定匹配 { stableMatch++; PrintResult(boys, girls, UNIT_COUNT); } return; } for(int i = 0; i < boys[index].pCount; i++) //index随递归过程变大 { int gid = boys[index].perfect[i]; if(!IsPartnerAssigned(&girls[gid]) && IsFavoritePartner(&girls[gid], index)) //如果女孩没有对象,并且男孩在女孩的偏爱列表里 { boys[index].current = gid; girls[gid].current = index; SearchStableMatch(index + 1, boys, girls); boys[index].current = -1; //下一层递归回来后,要把前面的假设条件干掉,才能继续同层的循环 girls[gid].current = -1; } } }
static void DoListen(ConnectionRef conn) // Implements the "listen" command. First this does a listen RPC // to tell the server that this connection is now a listener. Next it // calls ConnectionRegisterListener to register a packet listener callback // (GotPacket, above) on the runloop. It then runs the runloop until its // stopped (by a SIGINT, via SIGINTRunLoopCallback, below). { int err; PacketListen request; PacketReply reply; InitPacketHeader(&request.fHeader, kPacketTypeListen, sizeof(request), true); err = ConnectionRPC(conn, &request.fHeader, &reply.fHeader, sizeof(reply)); if (err == 0) { err = reply.fErr; } if (err == 0) { err = ConnectionRegisterListener( conn, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, GotPacket, CFRunLoopGetCurrent() ); } if (err != 0) { PrintResult("listen", err, NULL); } else { fprintf(stderr, "%*s Press ^C to quit.\n", kResultColumnWidth, "listen"); CFRunLoopRun(); } }
int main() { CGI *cgi = NULL; HDF *hdf = NULL; hdf_init(&hdf); cgi_init(&cgi, hdf); sem_init(&cmd_sem, 0, 0); hdf_set_value(cgi->hdf,"Config.Upload.TmpDir","/tmp/cgiupload"); hdf_set_value(cgi->hdf,"Config.Upload.Unlink","0"); cgi_parse(cgi); Setup_MQ(IMG_MQ_SEND, IMG_MQ_RECEIVE); //bind Receive callback NotifySetup(&msg_queue_receive); if (AmbaIQPage_set_params (hdf) < 0) { PrintResult(STATUS_FAILURE); } else { while (1){ if (0 != mq_send (msg_queue_send, (char *)send_buffer, MAX_MESSAGES_SIZE, 0)) { LOG_MESSG("%s", "mq_send failed!"); sleep(1); continue; } break; } sem_wait(&cmd_sem); } //hdf_dump(hdf,"<br>"); return 0; }
int main() { InitializeInputData(); BreakCycles(); PrintResult(); return 0; }
void main(){ // Khai báo int n; int a[100]; Input(a,n); PrintResult(a,n); getch(); }
/************************************************* Function: SearchMoulde() Description:搜索模块,调用查找函数,如果返回值为空则提示是否退出,否则按设置朗读单词 Calls: SearchWord(),YesOrNo(),SpeakWord() Called By: main() Input: 存有26个字母表头信息的数组,存有设置信息的结点地址 Output: // 对输出参数的说明。 Return: // 函数返回值的说明 Others: *************************************************/ void SearchMoulde(WorData *alphabet[],SetUp *setinfo) { char *tip={" Use = to backspace, @ to clear the line, ` to exit"}; WorData *result=NULL; system("cls"); INTERFACE_COLOR_1; system("cls"); printf("\n%s\n",tip); #ifdef MSVC Sleep(1000); #else sleep(1000); #endif while (1) { //display the interface system("cls"); result=SearchWord(alphabet); if (result!=NULL) { PrintResult(result); if (setinfo->autospeak==YES) { SpeakWord(result,setinfo); } else { printf("\n\nDo you want to speak the word?:[ ]\b\b"); if (YesOrNo() == YES) { SpeakWord(result,setinfo); } else { break; } } } else { system("cls"); printf("\nDo you want to exit?:[ ]\b\b"); if (YesOrNo()==YES) { return; } else { //break; //出错 continue; } } }//end of while(1) }
void main() { int a[100]; int n; RandomArray(a,n); PrintArray(a,n); PrintResult(a,n); getch(); }
void PrintResult(int* Result,int TotalLoop,int Index) { if (TotalLoop ==0) { return ; } printf("%d \n",*(Result+Index)); PrintResult(Result,TotalLoop-1,Index+1); }
int main(int argc, char* argv[]) { KM_MATCH km_match; InitGraph(&km_match, X); if(Kuhn_Munkres_Match(&km_match)) { PrintResult(&km_match); } return 0; }
int main() {//已经全部转换成小写。's会被统计成s, 连字符-没考虑 FILE *f_open; f_open=fopen("lower.txt","rb"); FILE *write[26]; FILE *INDEX; INDEX=fopen("index.txt","wb"); char name[26][6]; Info *hash[26]; for(int i=0;i<26;i++) { name[i][0]=i+'A'; strncpy(name[i]+1,".txt\0",5); write[i]=fopen(name[i],"wb"); hash[i]=CreateInfo(); } char c; char word[20]; char *p; int words=0; while((c=fgetc(f_open))!=EOF) { while(!isalpha(c)) if((c=fgetc(f_open))==EOF) goto toend; words++; p=word; while(isalpha(c)) { *p++=c; if((c=fgetc(f_open))==EOF) { *p='\0'; break; } } *p='\0'; assert(isalpha(word[0])); IfExsist(hash[word[0]-'a'],word); } toend:; PrintHash(hash,INDEX); for(int i=0;i<26;i++) { WordQsort(hash[i]); PrintResult(hash[i],write[i],i); } fclose(f_open); for(int i=0;i<26;i++) fclose(write[i]); fclose(INDEX); return 0; }
void TestSuite::Run(void) { Setup(); for (vector<TestCase *>::const_iterator cit = cases_.begin(); cit != cases_.end(); ++cit) { (*cit)->Run(); if ((*cit)->result_) passedCasesCount_++; } if (passedCasesCount_ == GetCaseCount()) { PrintResult(GetFormattedSuiteTitle() + "All cases passed!", true); } else { char descri[128] = { 0 }; sprintf(descri, "%sTotally %d out of %d test cases failed.", GetFormattedSuiteTitle().c_str(), GetCaseCount() - passedCasesCount_, GetCaseCount()); string descriStr(descri); PrintResult(descriStr, false); } Cleanup(); }
// Function that displays dealer's hand until the dealer hand reaches a value of 17 void CBlackJack::DealerOptionsAndPlay() { while (!Dealer.IsBusted() && !Dealer.IsReadyToStand()) { Hit(Dealer); Dealer.PrintScore(); } // end while loop if(Dealer.IsBusted()) PrintResult(DEALER_BUST, Dealer.GetName(), 0); else PrintPlayerStandMessage(Dealer.GetName()); return; }
int main(int argc, const char *argv[]) { int i, N = 0; ElementType * A = NULL; printf("Input N :"); scanf("%d", &N); A = (ElementType*) malloc(sizeof(ElementType) * N); printf("Input N number:\n"); for (i = 0; i < N; ++i) scanf("%lf", &A[i]); InsertionSort(A, N); PrintResult(A, N); return 0; }
void TestContestant(char *ContestantName) { printf("\n>>> Contestant : %s\n", ContestantName); char TesterCommand[1024]; int LastReturnValue = 0; for (int i = 0; i < CommandCount; i++) { if (strcmp(Config[i].MainCommand, "#TC") == 0) { char sExecutable[256], Executable[256]; char sExecutableParameters[256], ExecutableParameters[256]; char sCheckerCommand[256], CheckerCommand[256]; strrpl(sExecutable, Config[i].Executable, "$(CONTESTANT)", ContestantName); strrpl(Executable, sExecutable, "%20", " "); strrpl(sExecutableParameters, Config[i].ExecutableParameters, "$(CONTESTANT)", ContestantName); strrpl(ExecutableParameters, sExecutableParameters, "%20", " "); strrpl(sCheckerCommand, Config[i].CheckerCommand, "$(CONTESTANT)", ContestantName); strrpl(CheckerCommand, sCheckerCommand, "%20", " "); PrintPrompt(Config[i].Identifier); char TesterCommand[1024]; sprintf(TesterCommand, "./tester %d \"%s\" \"%s\" %d %d \"%s\" RESULT", Config[i].TestType, Executable, ExecutableParameters, Config[i].TimeLimit, Config[i].MemoryLimit, CheckerCommand/*, Config[i].OutputFile, Config[i].AnswerFile*/); LastReturnValue = system(TesterCommand); PrintResult(); } else if (strcmp(Config[i].MainCommand, "#N0") == 0) { if (LastReturnValue != 0) { i += atoi(Config[i].Parameter); } } else { char ParsedContestantCommand[1024]; char ParsedSpaceCommand[1024]; strrpl(ParsedContestantCommand, Config[i].MainCommand, "$(CONTESTANT)", ContestantName); strrpl(ParsedSpaceCommand, ParsedContestantCommand, "%20", " "); LastReturnValue = system(ParsedSpaceCommand); } } printf("\n"); }
void PrintResultComputation(HRESULT resultCode, size_t rows, floattype *result) { switch(resultCode){ case S_OK: PrintResult(result, rows); break; case S_FALSE: std::cout << "cannot solve"; break; case E_INVALIDARG: std::cout << "function's parameters mismatch"; break; default: std::cout << "Unexpected error"; } }
static void DoNOP(ConnectionRef conn) // Implements the "nop" command by doing a NOP RPC with the server. { int err; PacketNOP request; PacketReply reply; InitPacketHeader(&request.fHeader, kPacketTypeNOP, sizeof(request), true); err = ConnectionRPC(conn, &request.fHeader, &reply.fHeader, sizeof(reply)); if (err == 0) { err = reply.fErr; } PrintResult("nop", err, NULL); }
/** * Actions execute method. */ DWORD ExecuteAdtMoveObjectAction(IN AdtActionTP action) { DWORD dwError = 0; AppContextTP appContext = (AppContextTP) ((AdtActionBaseTP) action)->opaque; PrintStderr(appContext, LogLevelVerbose, "%s: Moving AD object %s to %s,%s ...\n", appContext->actionName, action->moveObject.from, appContext->oName, action->moveObject.to); dwError = MoveADObject(appContext, action->moveObject.from, appContext->oName, action->moveObject.to); if(dwError && IsMultiForestMode(action)) { SwitchConnection(action); dwError = MoveADObject(appContext, action->moveObject.from, appContext->oName, action->moveObject.to); } ADT_BAIL_ON_ERROR_NP(dwError); PrintStderr(appContext, LogLevelVerbose, "%s: Done moving AD object\n", appContext->actionName); if(appContext->gopts.isPrintDN) { PrintResult(appContext, LogLevelNone, "%s,%s\n", appContext->oName, action->moveObject.to); goto cleanup; } if(!appContext->gopts.isPrintDN) { if(!appContext->gopts.isQuiet) { PrintResult(appContext, LogLevelNone, "New DN: %s,%s", appContext->oName, action->moveObject.to); } } cleanup: return dwError; error: goto cleanup; }
static void DoShout(ConnectionRef conn, const char *message) // Implements the "shout" command by sending a shout packet to the server. // Note that this is /not/ an RPC. // // The server responds to this packet by echoing it to each registered // listener. { int err; PacketShout request; InitPacketHeader(&request.fHeader, kPacketTypeShout, sizeof(request), false); snprintf(request.fMessage, sizeof(request.fMessage), "%s", message); err = ConnectionSend(conn, &request.fHeader); PrintResult("shout", err, message); }
// ----------------------------------------------------------------------------- // CResultCollector::VisitL // ----------------------------------------------------------------------------- // void CResultCollector::VisitL( CNSPTest& aTest ) { CBufFlat* buffer = CBufFlat::NewL( 300 ); CleanupStack::PushL( buffer ); RBufWriteStream stream; stream.Open( *buffer ); CleanupClosePushL( stream ); aTest.ExternalizeL( stream ); TPckgBuf<TResult> pkgIn; pkgIn.Copy( buffer->Ptr(0) ); PrintResult( pkgIn() ); CleanupStack::PopAndDestroy(); CleanupStack::PopAndDestroy( buffer ); }