static void RecursiveSave( int depth, int to, int *record, TreeDataType *ptd ) { int first, i; /* to find first interval */ for ( first = record[ depth - 1 ] + 1; ptd->interval[ first ].from < to && first < ptd->nInterval; first++ ) ; if ( first == ptd->nInterval ) { SaveRecord( record + 1, depth - 1, ptd ); return; } record[ depth ] = first; RecursiveSave( depth + 1, ptd->interval[ first ].to, record, ptd ); /* for each interval which intersects first */ for ( i= first + 1; PhraseIntervalIntersect( ptd->interval[ first ], ptd->interval[ i ] ) && i < ptd->nInterval; i++ ) { record[ depth ] = i; RecursiveSave( depth + 1, ptd->interval[ i ].to,record, ptd ); } }
bool Loop() { size_t row = 0; if (!(IsBOF() && IsEOF())) for (MoveFirst(); !IsEOF(); MoveNext(), row++) { //TRACE(_T("row %3d\n"), row); NewRecord(); for (int i = 0; i < GetFieldCount(); i++) { COleVariant var; GetFieldValue(i, var); SaveField(i, var); } SaveRecord(); } return true; }
// В конструкторе формы внесли изменения, чтобы передать в нее булевский параметр EditTemplateString2::EditTemplateString2 (bool priz, QWidget *parent):QDialog(parent), ui(new Ui::EditTemplateString2()) { ui->setupUi(this); connect (ui->buttonBox,SIGNAL(accepted()),this,SLOT(SaveRecord())); // Кнопка 'Ok' connect (ui->buttonBox,SIGNAL(rejected()),this,SLOT(CloseWindow())); // Кнопка 'Отмена' // Выставим заголовок окна в зависимости от того в каком режиме вызвали aPriz = priz; if (aPriz == true) {setWindowTitle(tr("Добавление новой записи в шаблон"));} else {setWindowTitle(tr("Редактирование записи в шаблоне")); } // Грузим установки формы из конфигурационного файла qTC->formLoad(this, FormSetFile, false); }
void CKeyBoardDlg::OnSysCommand(UINT nID, LPARAM lParam) { if (nID == IDM_CLEAR_RECORD) { BYTE bToken = COMMAND_KEYBOARD_CLEAR; m_iocpServer->Send(m_pContext, &bToken, 1); m_edit.SetWindowText(""); } else { if (nID == IDM_SAVE_RECORD) { SaveRecord(); } else { CDialog::OnSysCommand(nID, lParam); } } }
void End() { setcolor(WHITE); setfont(30, 0,"宋体"); if(win == 1) { end_win++; end_frist++; if(end_now == 1) { end_lian++; } else { end_now = 1; end_lian = 1;} char ss[100] = " you win! "; outtextxy(270, 30, ss); Speak(1,end_lian); } else { end_lose++; end_frist++; if(end_now == 2) { end_lian++; } else { end_now = 2; end_lian = 1;} char ss[100] = " you lose! "; outtextxy(270, 30, ss); Speak(2,end_lian); } setfont(30, 0,"宋体"); char sh[100] = "请按回车键重来"; outtextxy(250 , 80 , sh); SaveRecord(); setfont(20, 0,"宋体"); char ss[100] = "当前比分:"; outtextxy(500 , 20 , ss); itoa(end_win,ss,10); itoa(end_lose,sh,10); strcat(ss," : "); strcat(ss,sh); outtextxy(600 , 20 , ss); outtextxy(530 , 60 ,"朽木出品"); }
void main() { int i; char s[128]; struct ADDRESS address[MAX];/*定义结构体数组*/ int num;/*保存记录数*/ clrscr(); while(1) { clrscr(); printf("********************MENU*******************\n\n"); printf("| 0: Input records |\n"); printf("| 1: List records in the file |\n"); printf("| 2: Delete a record |\n"); printf("| 3: Insert a record to the list |\n"); printf("| 4: Save records to the file |\n"); printf("| 5: Load records from the file |\n"); printf("| 6: Quit |\n\n"); printf("*******************************************\n"); do{ printf("\n Input your choice(0~6):"); /*提示输入选项*/ scanf("%s",s); /*输入选择项*/ i=atoi(s); /*将输入的字符串转化为整型数*/ }while(i<0||i>6); /*选择项不在0~11之间重输*/ switch(i) /*调用主菜单函数,返回值整数作开关语句的条件*/ { case 0:num=InputRecord(address);break;/*输入记录*/ case 1:ListRecord(address,num);break; /*显示全部记录*/ case 2:num=DeleteRecord(address,num);break; /*删除记录*/ case 3:num=InsertRecord(address,num); break; /*插入记录*/ case 4:SaveRecord(address,num);break; /*保存文件*/ case 5:num=LoadRecord(address); break; /*读文件*/ case 6:exit(0); /*如返回值为11则程序结束*/ } } }
void CRacingFrame::CoreFrame() { while(1){ system("CLS"); IntroScreen(); cout<<"Input your choice:"; int choice; cin>>choice; switch (choice) { case 1: { if(PlayerCar!=NULL) delete PlayerCar; PlayerCar=NULL; RunGame(); system("CLS"); char yes_no=' '; while(yes_no!='y'&&yes_no!='n'){ fflush(stdin); cout<<"Do you want to save your record?(y/n):"; cin>>yes_no; } if(yes_no=='y') { LoadRecord(); string _Name; fflush(stdin); cout<<"Input your name:"; getline(cin,_Name); CPlayer record_after_play(_Name,PlayerCar->getCarType(),Point); Player_Record.push_back(record_after_play); SortScore(); SaveRecord(); } if(yes_no=='n') { fflush(stdin); Sleep(500); } break; } case 2: { CMapRacing::SetColor(2); LoadRecord(); ShowRecord(); CMapRacing::SetColor(0); break; } case 3: { CMapRacing::SetColor(3); CustomCar(); CMapRacing::SetColor(0); break; } case 4: break; default: { cout<<"Oopp! You got a wrong choice!"; Sleep(500); break; } } if(choice==4) { system("CLS"); cout<<"You was out of game"; Sleep(500); break; } } }
void VideoAndSound() { VideoCapture capture; //capture.open("rtsp://*****:*****@192.168.1.65/Streaming/Channels/1"); //����ͷ1 capture.open("rtsp://*****:*****@192.168.1.141:554/axis-media/media.amp"); // ����ͷ2 //capture.open("rtsp://service:@10.153.33.11/?line=1$camera"); //�˴�ΰ ���� //capture.open(0); //open ���ݱ�Ŵ�����ͷ //AVI or ASF // MPEG4 CV_FOURCC('D', 'I', 'V', 'X') // MJPG CV_FOURCC('M', 'J', 'P', 'G') VideoWriter writer("VideoTestDemo.avi", CV_FOURCC('M', 'J', 'P', 'G'), 30.0, Size(640, 480)); std::cout << "-------------" << std::endl; if (!capture.isOpened()) { std::cout << "Read video Failed !" << std::endl; return; } //cv::VideoCapture capture; cv::Mat frame; cv::namedWindow("video test"); int frame_num = 800; //��ʼ¼�� StartRecord(); //for (;;) { // if (!capture.read(frame)) { // std::cout << "No frame" << std::endl; // cv::waitKey(); // } // writer << frame; // cv::imshow("Output Window", frame); // if (cv::waitKey(1) >= 0) break; //} for (int i = 0; i < frame_num - 1; ++i) { capture >> frame; capture.read(frame); //���۽���ǰ imshow("video test", frame); writer << frame; //���۽����� ��Ƶ�洢��¼���������� //writer << fisheye2pano2(frame); //frame = fisheye2pano2(frame); //imshow("fisheyevideo test", frame); if (cv::waitKey(30) == 'q') { break; } } //������Ƶ StopRecord(); SaveRecord(); cv::destroyWindow("video test"); //cv::destroyAllWindows(); capture.release(); Encode(); }
void Board::Update(float timeStep) { if (gameOver_) { if (score_ > record_) { record_ = score_; SaveRecord(); } Restart(); return; } selectionNode_->Rotate(Quaternion(0.0f, timeStep * 50, 0.0f)); if (Path::GetTotalCount() > 0) return; if (needCheckLines_) { if (CheckLines()) { needSpawnBalls_ = false; } needCheckLines_ = false; // может быть что поле полностью занято, новых шаров спанить не надо и ходить некуда // не работает чот gameOver_ = true; for (int i = 0; i < height_; i++) { for (int j = 0; j < width_; j++) { if (!board_[i][j] || board_[i][j]->GetBallState() == BS_GHOST) { gameOver_ = false; break; } } } if (gameOver_) return; } if (needSpawnBalls_) { for (int i = 0; i < numAddBalls_; i++) { if (!SpawnBall()) { gameOver_ = true; return; } } if (difficulty_ <= D_NORMAL) { for (int i = 0; i < numAddBalls_; i++) CreateBall(true); } needSpawnBalls_ = false; } UIElement* uiRoot = GetSubsystem<UI>()->GetRoot(); Text* t = static_cast<Text*>(uiRoot->GetChild("Score", true)); t->SetText("Score: " + String(score_)); t = static_cast<Text*>(uiRoot->GetChild("Colors", true)); t->SetText("Colors: " + String(numColors_)); t = static_cast<Text*>(uiRoot->GetChild("LineLength", true)); t->SetText("Line length: " + String(lineLength_)); t = static_cast<Text*>(uiRoot->GetChild("Record", true)); t->SetText("Record: " + String(record_)); // нужно выбрасывать шары если после уделаения линий поле пустое }
p_npaspuskForm::p_npaspuskForm(bool AddEdit, int recnum, QWidget *parent) : QDialog(parent), ui(new Ui::p_npaspuskForm) { ui->setupUi(this); // Соединяем сигналы со слотами: connect (ui->buttonBox, SIGNAL(accepted()), this, SLOT (SaveRecord())); //кнопка "Ok" connect (ui->buttonBox, SIGNAL(rejected()), this, SLOT (CloseWindow())); // кнопка "Закрыть" // Грузим установки формы из конфигурационного файла qTC->formLoad(this, FormSetFile, false); // Если жобавляем новую запись, то идем сюда if (AddEdit == true) { QString tmpString = tr("Новое погружение "); setWindowTitle(tmpString.append(getCurrentTS().typeTS)); //Наименование ТС ui->labelTSName->setText(getCurrentTS().nameTS); // Найдем макс № погружения и услужливо подставим его // Если при вычислении max индекса возникла ошибка, ф-ция возвращает '-1' int maxInt = MaxCode("z18_spts.p_sgaspusk","nomp"); // Если почему-то max № не выбрался - пишем в Edit '1' if (maxInt == -1) { ui->lineEditNumber->setText("1"); } else { maxInt++; ui->lineEditNumber->setText(QString::number(maxInt)); } // берем текущую дату QDate curdate = QDate::currentDate(); ui->dateEditPogruzh->clear(); ui->dateEditPogruzh->setDate(curdate); // берем текущее время QTime curtime = QTime::currentTime(); ui->timeEditStartPogruzh->clear(); ui->timeEditStartPogruzh->setTime(curtime); } else // Если редактируем существующую запись, то идем сюда { /* QSqlQuery QPogruzh; // value: 0 1 2 3 4 5 6 7 QPogruzh.prepare("SELECT code,name,nomp,datep,begintime,endtime,codesh,prizn FROM z18_spts.p_sgapred WHERE code = :precnum"); QPogruzh.bindValue(":precnum",recnum); if (!QPogruzh.exec()) { QMessageBox::critical(0, tr("Редактирование записи"), msgErrorOpenEditRecord.toLatin1(), QMessageBox::Ok); CloseWindow(); } QPogruzh.first(); QString tmpString = tr("Погружение №").append(QPogruzh.value(2).toString()); setWindowTitle(tmpString); ui->labelTSName->setText(getCurrentTS().nameTS); ui->lineEditNumber->setText(QPogruzh.value(2).toString()); // берем дату погружения из записи QDate pogrdate = QPogruzh.value(3).toDate(); ui->dateEditPogruzh->clear(); ui->dateEditPogruzh->setDate(pogrdate); // берем время начала из записи QTime pogrstarttime = QPogruzh.value(4).toTime(); ui->timeEditStartPogruzh->clear(); ui->timeEditStartPogruzh->setTime(pogrstarttime); // берем время конца из записи QTime pogrendtime = QPogruzh.value(5).toTime(); ui->timeEditEndPogruzh->clear(); ui->timeEditEndPogruzh->setTime(pogrendtime); // Готов или не готов bool YesNoReady = QPogruzh.value(7).toBool(); if (YesNoReady == false) { ui->sostLabel->setText(tr("Не готов")); ui->sostLabel->setPalette(QPalette(getNotReadyColor())); } else { ui->sostLabel->setText(tr("Готов")); ui->sostLabel->setPalette(QPalette(getReadyColor())); } */ } }
bool ScanCacheSave(ScanCache* self, const char* fn, MemoryMappedFile* prev_mapping, MemAllocHeap* heap) { TimingScope timing_scope(nullptr, &g_Stats.m_ScanCacheSaveTime); MemAllocLinear* scratch = self->m_Allocator; MemAllocLinearScope scratch_scope(scratch); ScanCacheWriter writer; ScanCacheWriterInit(&writer, heap); // Save new view of the scan cache // // Algorithm: // // - Get all records from the dynamic table (stuff we put in this session) const uint32_t record_count = self->m_RecordCount; ScanCache::Record **dyn_records = LinearAllocateArray<ScanCache::Record*>(scratch, record_count); { uint32_t records_out = 0; for (uint32_t ti = 0, tsize = self->m_TableSize; ti < tsize; ++ti) { ScanCache::Record* chain = self->m_Table[ti]; while (chain) { dyn_records[records_out++] = chain; chain = chain->m_Next; } } CHECK(records_out == record_count); } // - Sort these records in key order (by SHA-1 hash) std::sort(dyn_records, dyn_records + record_count, SortRecordsByHash); const ScanData *scan_data = self->m_FrozenData; uint32_t frozen_count = scan_data ? scan_data->m_EntryCount : 0; const HashDigest *frozen_digests = scan_data ? scan_data->m_Keys.Get() : nullptr; const ScanCacheEntry *frozen_entries = scan_data ? scan_data->m_Data.Get() : nullptr; const uint64_t *frozen_times = scan_data ? scan_data->m_AccessTimes.Get() : nullptr; const uint8_t *frozen_access = self->m_FrozenAccess; const uint64_t now = time(nullptr); // Keep old entries for a week. const uint64_t timestamp_cutoff = now - 60 * 60 * 24 * 7; auto key_dynamic = [=](size_t index) -> const HashDigest* { return &dyn_records[index]->m_Key; }; auto key_frozen = [=](size_t index) { return frozen_digests + index; }; auto save_dynamic = [&writer, dyn_records, now](size_t index) { SaveRecord( &writer, &dyn_records[index]->m_Key, dyn_records[index]->m_Includes, dyn_records[index]->m_IncludeCount, dyn_records[index]->m_FileTimestamp, now); }; auto save_frozen = [&](size_t index) { uint64_t timestamp = frozen_times[index]; if (frozen_access[index]) timestamp = now; if (timestamp > timestamp_cutoff) { SaveRecord( &writer, frozen_digests + index, frozen_entries[index].m_IncludedFiles.GetArray(), frozen_entries[index].m_IncludedFiles.GetCount(), frozen_entries[index].m_FileTimestamp, timestamp); } }; TraverseSortedArrays(record_count, save_dynamic, key_dynamic, frozen_count, save_frozen, key_frozen); // Unmap the previous file from RAM so we can overwrite it on Windows. MmapFileUnmap(prev_mapping); self->m_FrozenData = nullptr; bool result = ScanCacheWriterFlush(&writer, fn); ScanCacheWriterDestroy(&writer); return result; }