bool isPalindrome(ListNode* head) { if (! head) return true; int len = ::lenList(head); if (len == 1) return true; ListNode* mid1 = head; for (int i=0; i<len/2-1; ++i) mid1 = mid1->next; ListNode* mid2 = mid1->next; ListNode* left = head; ListNode* right = mid2; mid1->next = NULL; if (len % 2) { right = right->next; mid2->next = NULL; } showList(left); showList(right); right = reverseList(right); showList(right); while (left && right) { if (left->val != right->val) return false; left = left->next; right = right->next; } return true; }
int main() { Node* list = NULL; list = addElement(list, 6); list = addElement(list, 6); list = addElement(list, 6); list = addElement(list, 6); list = addElement(list, 6); list = addElement(list, 6); list = addElement(list, 5); showList(list); list = removeElements(list, 6); showList(list); return 0; }
void LLLocationInputCtrl::onTextEntry(LLLineEditor* line_editor) { KEY key = gKeyboard->currentKey(); MASK mask = gKeyboard->currentMask(TRUE); // Typing? (moving cursor should not affect showing the list) bool typing = mask != MASK_CONTROL && key != KEY_LEFT && key != KEY_RIGHT && key != KEY_HOME && key != KEY_END; bool pasting = mask == MASK_CONTROL && key == 'V'; if (line_editor->getText().empty()) { prearrangeList(); // resets filter hideList(); } else if (typing || pasting) { prearrangeList(line_editor->getText()); if (mList->getItemCount() != 0) { showList(); focusTextEntry(); } else { // Hide the list if it's empty. hideList(); } } LLComboBox::onTextEntry(line_editor); }
void userMenu(user *userList) { int choose = 0; printf("==========================\n"); printf("------ MENU USUÁRIO ------\n"); printf("==========================\n"); printf("[1]CADASTRO\n"); //Coloca novo usuário no fim da lista printf("[2]ALTERAR\n"); //Altera um usuário na lista printf("[3]CONSULTAR\n"); //Consulta um dado usuário na lista printf("[4]LISTAR\n"); //Lista todos os usuários da lista printf("[5]EXCLUIR\n"); //Exclui usuário da lista printf("[6]VOLTAR\n"); scanf("%i", &choose); fflush(stdin); switch(choose) { case 1: userRegister(userList); break; case 2: userModify(userList); break; case 3: userSearch(userList); break; case 4: showList(userList); break; case 5: userDelete(userList); break; case 6: break; default: printf("OPÇÃO INVÁLIDA\n"); } }
void QgsLocatorWidget::triggerSearchAndShowList() { if ( mProxyModel->rowCount() == 0 ) performSearch(); else showList(); }
MainWindow::MainWindow() { QMenu *fileMenu = new QMenu(tr("&File")); fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence(tr("Ctrl+Q", "File|Exit"))); QMenu *actionsMenu = new QMenu(tr("&Actions")); actionsMenu->addAction(tr("&Highlight List Items"), this, SLOT(highlightListItems())); actionsMenu->addAction(tr("&Show Current List"), this, SLOT(showList())); QMenu *insertMenu = new QMenu(tr("&Insert")); insertMenu->addAction(tr("&List"), this, SLOT(insertList()), QKeySequence(tr("Ctrl+L", "Insert|List"))); menuBar()->addMenu(fileMenu); menuBar()->addMenu(insertMenu); menuBar()->addMenu(actionsMenu); editor = new QTextEdit(this); document = new QTextDocument(this); editor->setDocument(document); setCentralWidget(editor); setWindowTitle(tr("Text Document List Items")); }
int menu() { int option; char flag = 'y'; do { printf( "\n-- MENU --\n1 - INSERIR item no FIM da lista" "\n2 - INSERIR item em POSICAO especifica" "\n3 - REMOVER item por POSICAO" "\n4 - REMOVER item por VALOR" "\n5 - MOSTRAR lista" "\n6 - Encerrar o programa" "\n\nDigite a sua opcao : " ); scanf( "%u", &option ); switch( option ) { case 1: insertItemEndList(); break; case 2: insertItem(); break; case 3: deleteItemPosition(); break; case 4: deleteItemValue(); break; case 5: showList(); break; case 6: flag = 'n'; break; } } while( flag == 'y' ); return 0; }
void MainWindow::initData() { std::ifstream monFichier; std::string extension = "./sauve.txt"; std::vector<std::string> myLine; std::string title, autor, editor, style, resume, actor; int piste, editorYear; monFichier.open(extension.c_str()); lib.clear(); if(monFichier) { while(monFichier) { std::string ligne; getline(monFichier, ligne); myLine = split(ligne, "//"); if (myLine[0] == "<Book>") { title = myLine[1]; autor = myLine[2]; resume = myLine[3]; editor = myLine[4]; editorYear = atoi(myLine[5].c_str()); Book* book = new Book(title, autor, resume, editorYear, editor); lib.push_back(book); myLine.clear(); } else if (myLine[0] == "<CD>") { title = myLine[1]; autor = myLine[2]; style = myLine[3]; piste = atoi(myLine[4].c_str()); CD* cd = new CD(title, autor, style, piste); lib.push_back(cd); myLine.clear(); } else if (myLine[0] == "<Movie>") { title = myLine[1]; autor = myLine[2]; resume = myLine[3]; style = myLine[4]; actor = myLine[5]; Movie* movie = new Movie(title, autor, resume, style, actor); lib.push_back(movie); myLine.clear(); } } } else { std::cout<<"ERREUR: Impossible d'ouvrir le fichier "<<extension<<std::endl; } monFichier.close(); showList(); }
int main(){ while(1){ printf("1)createList 2)showList 3)insertNode 4)deleteNode\n"); scanf("%d", &input); switch(input){ case 1: createList(); break; case 2: showList(); break; case 3: int insertData[2]={0,0}; *insertData = insertRequest(); node* iNode; iNode = (node*)malloc(sizeof(node)); iNode->name = insertData[0]; insertNode(iNode,insertData[1]); break; case 4: break; case 5: printf("離開程式!\n"); return 0; default: break; } } }
void LLSearchComboBox::onTextEntry(LLLineEditor* line_editor) { KEY key = gKeyboard->currentKey(); if (line_editor->getText().empty()) { prearrangeList(); // resets filter hideList(); } // Typing? (moving cursor should not affect showing the list) else if (key != KEY_LEFT && key != KEY_RIGHT && key != KEY_HOME && key != KEY_END) { prearrangeList(line_editor->getText()); if (mList->getItemCount() != 0) { showList(); focusTextEntry(); } else { // Hide the list if it's empty. hideList(); } } LLComboBox::onTextEntry(line_editor); }
void ProcList::showCallers(const Database::Symbol *symbol) { list = database->getCallers(symbol); sortList(); showList(0); }
void ProcList::showMainList(const Database::Symbol *symbol) { list = database->getMainList(); sortList(); // find 'symbol' in the list // will default to the top symbol if not found size_t foundat = 0; for (size_t i=0;i<list.items.size();i++) { const Database::Symbol *sym = list.items[i].symbol; if (sym == symbol) { foundat = i; break; } } // DE: 20090325 remove compiler warning showList(static_cast<int>(foundat)); if (!list.items.empty()) { symbol = list.items[foundat].symbol; if (callersview) callersview->showCallers(symbol); if (calleesview) calleesview->showCallees(symbol); if(callStackView) callStackView->showCallStack(symbol); } }
void main() { cout<<"请输入有向图的节点,以-1,-1结束:"<<endl; int i,j; while(true) { cin>>i>>j; if(i==-1 && j==-1) break; if(i<0 || j<0) { cout<<"输入错误"<<endl; exit(1); } arc[i][j] = 1; cout<<endl; } cout<<"节点数(1~"<<MAX_NODE<<"):"<<endl; cin>>n; if(n<1 || n>MAX_NODE) { cout<<"错误,节点数必须是在1到"<<MAX_NODE<<"之间的数"<<endl; exit(1); } cout<<"输出邻接矩阵如下:"<<endl; showMGraph(); //进行拓扑排序 while(true) { //假设所有剩余的节点都没有入度 bool flag = true; for(int i=0; i<n; i++) { //如果是已被移除或者存在入度的节点 if((arc[i][i] == -1) || hasInRoad(i)) continue; //发现了一个入度,假设不成立 flag = false; //该节点没有入度 list[index++] = i; removeNode(i); //所有节点都已经排序 if(index>=n) { showList(); return; } } if(flag) { cout<<"该有向图含有环."<<endl; exit(2); } } }
void ImportNative::searchName() { QString s; fillSearchList("name"); s = m_chanName_text->GetText(); showList(tr("Select a channel name"), s, SLOT(gotName(QString))); }
void LLGestureComboList::draw() { LLUICtrl::draw(); if(mButton->getToggleState()) { showList(); } }
void MainWindow::on_btn_addDoc_clicked() { addDocument doc(&lib,this); doc.exec(); if(doc.close()) { showList(); } }
void ImportNative::searchChanID() { QString s; fillSearchList("chanid"); s = m_chanID_text->GetText(); showList(tr("Select a channel id"), s, SLOT(gotChanID(QString))); }
void ComboBox::notifyButtonPressed(WidgetPtr _sender, int _left, int _top, MouseButton _id) { if (MouseButton::Left != _id) return; mDropMouse = true; if (mListShow) hideList(); else showList(); }
void Combobox::mouseClick(int _y) { if (printed == 0) return; setColor(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); setPosition(7, 6); cout << "You chose: " << options[row]; showList(); }
void ImportNative::searchCallsign() { QString s; fillSearchList("callsign"); s = m_callsign_text->GetText(); showList(tr("Select a Callsign"), s, SLOT(gotCallsign(QString))); }
void ImportNative::searchChanNo() { QString s; fillSearchList("channum"); s = m_chanNo_text->GetText(); showList(tr("Select a channel number"), s, SLOT(gotChanNo(QString))); }
void MainWindow::on_actionAjouter_triggered() { addDocument doc(&lib, this); doc.exec(); if(doc.close()) { showList(); } }
void displayTable(struct linknode **hashTable) { int i; for(i=0; i < TABLESIZE; i++) { printf("%d: ", i); showList(hashTable[i]); printf("\n"); } }
int main() { pNode list1,list2; initList(&list1); initList(&list2); printf("Please input %d numbers to create list:\n",N); int i,elem; for(i=0;i<N;++i) { scanf("%d",&elem); insertList(&list1,elem); } showList("Before split",list1); fun(&list1,&list2); showList("After split,List1",list1); showList("After split,List2",list2); return 0; }
int main(int, char *[]) { static_assert(ShowInstance<Test>(), "Show instance error"); static_assert(!ShowInstance<int>(), "Show internal error"); std::cout << show(Test{}) << std::endl; std::cout << showList(std::list<Test>{}) << std::endl; return 0; }
int main(int argc, char *argv[]) { List l = newList(); FILE *f = fopen("collection.txt", "r"); getCollection(l, f); showList(l); getGraph(l, ListLength(l)); return 0; }
BOOL LLLocationInputCtrl::handleKeyHere(KEY key, MASK mask) { BOOL result = LLComboBox::handleKeyHere(key, mask); if (key == KEY_DOWN && hasFocus() && mList->getItemCount() != 0 && !mList->getVisible()) { showList(); } return result; }
void FiruMainWindow::searchWords() { m_loadTimer.stop(); QString pattern = m_ui.editInput->text(); if ( pattern.length() < 1 ) { showWordCount( QString( "There are %1 words in the dictionary.\n" "Enter some letters to filter by." ).arg( m_totalWords ) ); return; } int count = m_dictionary->count( pattern ); qDebug() << "Found" << count << "words for pattern " << pattern; if ( count < 1 ) { showWordCount( "No matches found." ); } else if ( count > 100 && pattern.length() < 5 ) { showWordCount( QString( "Found %1 matches.\nEnter more letters to filter by.").arg( count ) ); } else { if ( pattern == m_pattern ) { showList( m_words ); } else { if ( !pattern.startsWith( m_pattern ) || m_words.count() == 0 ) { m_pattern = pattern; // new pattern m_words = m_dictionary->findWords( m_pattern.left( 4 ), StartsWith ); } Word::List words = Word::filter( m_words, pattern, StartsWith ); showList( words ); } } }
void EditMetadataDialog::searchCompilationArtist() { QString s; searchList = Metadata::fillFieldList("compilation_artist"); s = m_metadata->CompilationArtist(); if (showList(tr("Select a Compilation Artist"), s)) { m_metadata->setCompilationArtist(s); fillWidgets(); } }
void EditMetadataDialog::searchAlbum() { QString s; searchList = Metadata::fillFieldList("album"); s = m_metadata->Album(); if (showList(tr("Select an Album"), s)) { m_metadata->setAlbum(s); fillWidgets(); } }