int main(void) { //выделяем память char** str = calloc(N, sizeof(char*)); if(str == NULL) { //free(str); printf("[error]"); return 0; } size_t i = 0; for( ; i < N; i++) { str[i] = calloc(STR_LEN, sizeof(char)); } int k = 0; int status = 0; //считываем строки while((status = scanf("%s", str[k])) != EOF) { if(status == 1) { } else { printf("[error]"); } k++; } //выделяем новый массив, в который попадают обработанные строки char** new_addr = trim(str, k); if(new_addr == NULL) { printf("[error]"); } //печатаем for(i = 0; i < k; i++) { printf("%s", str[i]); } clearMemory(new_addr, k); clearMemory(str, k); return 0; }
NO_SANITIZE_ADDRESS void OrphanedPagePool::decommitOrphanedPages() { ASSERT(ThreadState::current()->isInGC()); ASSERT(ThreadState::current()->heap().isAtSafePoint()); for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) { PoolEntry* entry = m_pool[index]; PoolEntry** prevNext = &m_pool[index]; while (entry) { BasePage* page = entry->data; // Check if we should reuse the memory or just free it. // Large object memory is not reused but freed, normal blink heap // pages are reused. // NOTE: We call the destructor before freeing or adding to the // free page pool. PageMemory* memory = page->storage(); if (page->isLargeObjectPage()) { page->~BasePage(); delete memory; } else { page->~BasePage(); clearMemory(memory); ThreadHeap::mainThreadHeap()->getFreePagePool()->addFreePage(index, memory); } PoolEntry* deadEntry = entry; entry = entry->next; *prevNext = entry; delete deadEntry; } } }
TransmissionDialog::TransmissionDialog(AbstractDiagInterface *diagInterface, QString language) : ControlUnitDialog(tr("Transmission Control Unit"), diagInterface, language) { // *** Initialize global variables: _content_DCs = NULL; _content_MBsSWs = NULL; _content_Adjustments = NULL; _mode = DCs_mode; // we start in Diagnostic Codes mode // Show information-widget: _infoWidget = new CUinfo_Transmission(); setInfoWidget(_infoWidget); _infoWidget->show(); // Setup functions: QPushButton *pushButton = addFunction(tr("&Diagnostic Codes"), QIcon(QString::fromUtf8(":/icons/chrystal/22x22/messagebox_warning.png")), true); pushButton->setChecked(true); connect( pushButton, SIGNAL( clicked() ), this, SLOT( DTCs() ) ); pushButton = addFunction(tr("&Measuring Blocks"), QIcon(QString::fromUtf8(":/icons/oxygen/22x22/applications-utilities.png")), true); connect( pushButton, SIGNAL( clicked() ), this, SLOT( measuringblocks() ) ); pushButton = addFunction(tr("&Adjustments"), QIcon(QString::fromUtf8(":/icons/chrystal/22x22/configure.png")), true); connect( pushButton, SIGNAL( clicked() ), this, SLOT( adjustments() ) ); _clearMemory_pushButton = addFunction(tr("Clear Memory"), QIcon(QString::fromUtf8(":/icons/chrystal/22x22/eraser.png")), false); connect( _clearMemory_pushButton, SIGNAL( clicked() ), this, SLOT( clearMemory() ) ); _clearMemory2_pushButton = addFunction(tr("Clear Memory 2"), QIcon(QString::fromUtf8(":/icons/chrystal/22x22/eraser.png")), false); connect( _clearMemory2_pushButton, SIGNAL( clicked() ), this, SLOT( clearMemory2() ) ); // NOTE: using released() instead of pressed() as workaround for a Qt-Bug occuring under MS Windows // Load/Show Diagnostic Code content: _content_DCs = new CUcontent_DCs_twoMemories(); setContentWidget(tr("Diagnostic Codes:"), _content_DCs); _content_DCs->show(); // Make GUI visible this->show(); // Connect to Control Unit, get data and setup GUI: setup(); }
//--------------------------------------------------------------------------- void ofQuickTimePlayer::closeMovie(){ //-------------------------------------- #ifdef OF_VIDEO_PLAYER_QUICKTIME //-------------------------------------- if (bLoaded == true){ DisposeMovie (moviePtr); DisposeMovieDrawingCompleteUPP(myDrawCompleteProc); moviePtr = NULL; width = height = 0; } //-------------------------------------- #endif //-------------------------------------- clearMemory(); bLoaded = false; }
Memory::Memory(unsigned int sizeinKB) { this->sizeInKB = sizeinKB; unsigned int sizeInBytes = sizeinKB * 1024; memoryBlock = new uint8_t[sizeInBytes]; clearMemory(); }
void MatchedFilter::resize(int maxShingleSize, int maxDBSize){ if(MatchedFilter::maxShingleSize) clearMemory(); MatchedFilter::maxShingleSize = maxShingleSize; MatchedFilter::maxDBSize = maxDBSize; int j; // Cross-correlation matrix D = new float*[maxShingleSize]; if(!D) err("Could not allocate for D matrix rows.\n"); for( j=0; j < maxShingleSize ; j++ ){ D[j]=new float[ maxDBSize ]; if(!D[j]) err("Could not allocate for D matrix cols.\n"); } // Matched filter matrix DD = new float[ maxDBSize ]; if(!DD) err("Could not allocate for DD matrix rows.\n"); // Allocate for L2 norm vectors qNorm = new float[ maxShingleSize ]; // query is one shingle of length W sNorm = new float[ maxDBSize ]; // source shingles of length W }
int main() { freopen("random_matrixes.txt", "r", stdin); setbuf(stdout, NULL); int T, i, j; scanf("%d", &T); while (T--) { // inputs: scanf("%d %d", &N, &M); for (i = 0; i < N; i++) for (j = 0; j < M; j++) scanf("%d", &a[i][j]); printf("Matrix Before: \n"); printMatrix(); // solve & outputs: nullifyMatrix(); printf("Matrix After: \n"); printMatrix(); // clear memory: clearMemory(); } return 0; }
BOOT_CODE pptr_t allocate_bi_frame( node_id_t node_id, word_t num_nodes, vptr_t ipcbuf_vptr ) { pptr_t pptr; /* create the bootinfo frame object */ pptr = alloc_region(BI_FRAME_SIZE_BITS); if (!pptr) { printf("Kernel init failed: could not allocate bootinfo frame\n"); return 0; } clearMemory((void*)pptr, PAGE_BITS); /* initialise bootinfo-related global state */ ndks_boot.bi_frame = BI_PTR(pptr); ndks_boot.slot_pos_cur = BI_CAP_DYN_START; BI_PTR(pptr)->node_id = node_id; BI_PTR(pptr)->num_nodes = num_nodes; BI_PTR(pptr)->num_iopt_levels = 0; BI_PTR(pptr)->ipcbuf_vptr = ipcbuf_vptr; BI_PTR(pptr)->it_cnode_size_bits = CONFIG_ROOT_CNODE_SIZE_BITS; BI_PTR(pptr)->it_domain = ksDomSchedule[ksDomScheduleIdx].domain; return pptr; }
Socket::Socket(Types t) : sockType(t), currentState(Disconnected) { peerAddress = new addrinfo; clearMemory(*peerAddress); buffer = new char[PACKET_SIZE]; }
bool Socket::bindToAddress(const char *hostAddr, const char *servicePort) { struct addrinfo *result; struct addrinfo hints; clearMemory(hints); hints.ai_family = AF_INET; // hints.ai_socktype = SOCK_DGRAM; // if(getaddrinfo(hostAddr, servicePort, &hints, &peerAddress)) { std::cerr << "Cannot create addrinfo structure for " << hostAddr << std::endl; return false; } hints.ai_flags = AI_PASSIVE; addrinfo *local; getaddrinfo("localhost", servicePort, &hints, &local); for(result = peerAddress; result != 0; result = result->ai_next) { descriptor = socket(result->ai_family, result->ai_socktype, result->ai_protocol); // Socket initialization if(descriptor < 0) { // Error information std::cout << "Failed while creating socket!" << std::endl; } bool loc = true; for(int i = 2; i < 6; ++i) { if(local->ai_addr->sa_data[i] != result->ai_addr->sa_data[i]) { loc = false; break; } } if(loc) break; if(!bind(descriptor, result->ai_addr, result->ai_addrlen)) { break; } std::cout << "Cannot bind socket! - " << strerror(errno) << std::endl; close(descriptor); } peerAddress = result; if(peerAddress == 0) { std::cerr << "Error while connecting to the " << hostAddr << std::endl; return false; } else { currentState = Connected; getnameinfo(peerAddress->ai_addr, peerAddress->ai_addrlen, peerName, 300, 0, 0, 0); getnameinfo(peerAddress->ai_addr, peerAddress->ai_addrlen, peerIP, INET_ADDRSTRLEN, 0, 0, NI_NUMERICHOST); std::cout << "Binded to the " << peerName << '(' << peerIP << ')' << std::endl; } return true; }
void initialize(){ initializeFuncPtrArray(); clearMemory(); clearRegisters(); clearFregister(); clearDregister(); clearEregister(); clearMregister(); clearWregister(); }
void BfVM::reset() { qDebug("BfVM::reset()"); m_DP = 0; m_IP = 0; clearMemory(); m_inputBuffer->clear(); emit resetted(); #ifndef QT_NO_DEBUG listStates(); #endif }
void initialize() { clearMemory(); clearRegisters(); clearFregister(); clearDregister(); clearEregister(); clearMregister(); clearWregister(); initInstructions(); }
void PSD::clearData() { removeFromStorage(); layerIdIdxMap.clear(); pathMap.clear(); storageStarted = false; psd::PSDFile::clearData(); #ifdef LOAD_MEMORY clearMemory(); #else clearStream(); #endif }
//--------------------------------------------------------------------------- ofQuickTimePlayer::~ofQuickTimePlayer() { closeMovie(); clearMemory(); //-------------------------------------- #ifdef OF_VIDEO_PLAYER_QUICKTIME //-------------------------------------- if(allocated) delete[] offscreenGWorldPixels; if ((offscreenGWorld)) DisposeGWorld((offscreenGWorld)); //-------------------------------------- #endif //-------------------------------------- }
//-------------------------------------------------------------------- void ofQuickTimeGrabber::close(){ //--------------------------------- #ifdef OF_VIDEO_CAPTURE_QUICKTIME //--------------------------------- qtCloseSeqGrabber(); DisposeSGGrabCompleteBottleUPP(myGrabCompleteProc); //--------------------------------- #endif //--------------------------------- clearMemory(); }
/* initialize * Initializes a bunch of stuff. * Params: none * Returns: void * Modifies: W_valE, W_dstE */ void initialize() { clockCount = 0; stop = FALSE; initFwdStruct(); initializeFuncPtrArray(); initializeCC(); clearMemory(); clearRegisters(); clearFregister(); clearDregister(); clearEregister(); clearMregister(); clearWregister(); }
void PassiveScalarCell::initializeDistribution() { clearMemory(); int colors = PassiveScalarSingleton::getInstance()->getColorsQuantity(); int model = Shared::instance()->getGridConfig()->getModel(); f = new double[colors * model]; for (int i = 0; i < colors * model; i++) { f[i] = 0; } nextF = new double[colors * model]; for (int i = 0; i < colors * model; i++) { nextF[i] = 0; } p = new double[colors]; for (int i = 0; i < colors; i++) { p[i] = 0; } }
void menu(struct month *cur) { while(1) { int select; int node;//스케쥴 개수 printf("\n ┌── 목 록 ──┐\n │ │\n"); printf(" │ 1. 스케쥴 추가 │\n │ │\n"); printf(" │ 2. 스케쥴 제거 │\n │ │\n"); printf(" │ 3. 스케쥴 출력 │\n │ │\n"); printf(" │ 4. 스케쥴 검색 │\n │ │\n"); printf(" │ 5. 종료 │\n │ │\n"); printf(" └────────┘\n"); printf(" → "); scanf("%d", &select); getchar(); printf("\n"); node = countNode(cur);//node(스케쥴)의 개수 if(select == 1) { addSchedule(cur);//스케쥴 추가 } else if(select == 2) { removeSchedule(cur);//스케쥴 제거 writeFile(cur);//스케쥴 제거후 갱신된 현재 데이터를 텍스트파일에 출력(쓰기) } else if(select == 3) { printSchedule(cur);//스케쥴 출력 }else if(select ==4) { searchSchedule(cur);//스케쥴 검색 } else if(select ==5) { clearMemory(cur);//프로그램종료전 할당된 메모리를 제거시킨다. exit(1); } else{ printf(" ERROR !!\n"); continue; } } }
//-------------------------------------------------------------------- void ofDirectShowGrabber::close(){ //--------------------------------- #ifdef OF_VIDEO_CAPTURE_DIRECTSHOW //--------------------------------- if (bGrabberInited == true){ VI.stopDevice(device); bGrabberInited = false; } //--------------------------------- #endif //--------------------------------- clearMemory(); }
BOOT_CODE cap_t create_ipcbuf_frame(cap_t root_cnode_cap, cap_t pd_cap, vptr_t vptr) { cap_t cap; pptr_t pptr; /* allocate the IPC buffer frame */ pptr = alloc_region(PAGE_BITS); if (!pptr) { printf("Kernel init failing: could not create ipc buffer frame\n"); return cap_null_cap_new(); } clearMemory((void*)pptr, PAGE_BITS); /* create a cap of it and write it into the root CNode */ cap = create_mapped_it_frame_cap(pd_cap, pptr, vptr, false, false); write_slot(SLOT_PTR(pptr_of_cap(root_cnode_cap), BI_CAP_IT_IPCBUF), cap); return cap; }
void A4MemoryBank::initMemory(CvSize size, int aresizeFactor = 4) { clearMemory(); resizeFactor = aresizeFactor; mainSize = size; sizeFactored = cvSize(size.width/resizeFactor, size.height/resizeFactor); sizeII = cvSize(size.width + 1, size.height + 1); sizeFactoredII = cvSize(sizeFactored.width + 1, sizeFactored.height + 1); redChannel = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); greenChannel = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); blueChannel = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); redChannelResized = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); greenChannelResized = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); blueChannelResized = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); uBorders = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); dBorders = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); lBorders = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); rBorders = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); uBordersII = cvCreateImage(sizeII, IPL_DEPTH_32S, 1); dBordersII = cvCreateImage(sizeII, IPL_DEPTH_32S, 1); lBordersII = cvCreateImage(sizeII, IPL_DEPTH_32S, 1); rBordersII = cvCreateImage(sizeII, IPL_DEPTH_32S, 1); uBordersFactored = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); dBordersFactored = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); lBordersFactored = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); rBordersFactored = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); uBordersIIFactored = cvCreateImage(sizeFactoredII, IPL_DEPTH_32S, 1); dBordersIIFactored = cvCreateImage(sizeFactoredII, IPL_DEPTH_32S, 1); lBordersIIFactored = cvCreateImage(sizeFactoredII, IPL_DEPTH_32S, 1); rBordersIIFactored = cvCreateImage(sizeFactoredII, IPL_DEPTH_32S, 1); buffer = cvCreateImage(mainSize, IPL_DEPTH_8U, 1); bufferFactored = cvCreateImage(sizeFactored, IPL_DEPTH_8U, 1); }
cManager::cManager(vector<cSquare*> &vSquareVector) { vector<cSquare*> vOwnedProperties; //Uses A Const To Determine The Amount Of Rounds int managerRounds[amountOfRounds]; //Outputs A Welcoming Message To User cout << "Welcome To Monopoly." << endl; //Reads The Monopoly.txt File And Creates Pointers Of Classes retrieveFile(vSquareVector); //Uses The Amount Of Rounds Const To Determine The Random's Length roll(managerRounds); //Creates The Objects Of cPlayer Class. cPlayer Player1("Dog", 300, 0); cPlayer Player2("Car", 300, 0); //Uses The Amount Of Rounds To Determine Howmany Times To Loop for (int i = 0; i < amountOfRounds; i++) { // Splits Evenly For Each Use(Odd 1 Player , Even The Other) if (isOdd(i) == true) { diceLocationMove(Player1.getCurrentPosition(), managerRounds[i], Player1); squareLocation(Player1.getCurrentPosition(), Player1, Player2, vSquareVector); checkPlayerBalance(Player1); } else { diceLocationMove(Player2.getCurrentPosition(), managerRounds[i], Player2); squareLocation(Player2.getCurrentPosition(), Player2, Player1, vSquareVector); checkPlayerBalance(Player2); } } clearMemory(vSquareVector); }
BfVM::BfVM(QObject *parent) : QThread(parent), m_DP(0), m_IP(0), m_programSize(0), m_runDelay(200), m_memory(new Memtype[MAX_MEM_ADDR+1]), m_jmps(new BiHash<IPType,IPType>()), m_program(NULL), m_runTimer(new QTimer(this)), m_inputBuffer(new QQueue<Memtype>()), m_breakpoints(new QList<IPType>()), m_stateMachine(new QStateMachine(this)), ///// STATE INITIALIZATIONS m_stateGroup(new QState()), m_runGroup(new QState(m_stateGroup)), m_emptySt(new QState(m_stateGroup)), m_initializedSt(new QState(m_stateGroup)), m_steppingSt(new QState(m_runGroup)), m_runningSt(new QState(m_runGroup)), m_finishedSt(new QState(m_stateGroup)), m_waitingForInpSt(new QState(m_stateGroup)), m_breakpointSt(new QState(m_runGroup)), m_runHistorySt(new QHistoryState(m_runGroup)), m_clearSt(new QState(m_stateGroup))///// END OF STATE INITIALIZATION { qDebug() << "BfVM::BfVM()\nLargest address:" << MAX_MEM_ADDR; // initialize memory to all 0 clearMemory(); initializeStateMachine(); m_stateMachine->start(); ///////////////////////////////////////////////////////////////////////////////////// //// TIMER SETUP //////////////// m_runTimer->setInterval(m_runDelay); // running a program is just "single-stepping by the clock." connect(m_runTimer, SIGNAL(timeout()), this, SLOT(step())); }
NO_SANITIZE_ADDRESS void OrphanedPagePool::decommitOrphanedPages() { ASSERT(ThreadState::current()->isInGC()); #if ENABLE(ASSERT) // No locking needed as all threads are at safepoints at this point in time. for (ThreadState* state : ThreadState::attachedThreads()) ASSERT(state->isAtSafePoint()); #endif for (int index = 0; index < BlinkGC::NumberOfHeaps; ++index) { PoolEntry* entry = m_pool[index]; PoolEntry** prevNext = &m_pool[index]; while (entry) { BasePage* page = entry->data; // Check if we should reuse the memory or just free it. // Large object memory is not reused but freed, normal blink heap // pages are reused. // NOTE: We call the destructor before freeing or adding to the // free page pool. PageMemory* memory = page->storage(); if (page->isLargeObjectPage()) { page->~BasePage(); delete memory; } else { page->~BasePage(); clearMemory(memory); Heap::freePagePool()->addFreePage(index, memory); } PoolEntry* deadEntry = entry; entry = entry->next; *prevNext = entry; delete deadEntry; } } }
// Destructor: calls its own clean up function ClusterData::~ClusterData() { clearMemory(); }
//! [0] Calculator::Calculator(QWidget *parent) : QWidget(parent) { sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; //! [0] //! [1] display = new QLineEdit("0"); //! [1] //! [2] display->setReadOnly(true); display->setAlignment(Qt::AlignRight); display->setMaxLength(15); QFont font = display->font(); font.setPointSize(font.pointSize() + 8); display->setFont(font); //! [2] //! [4] for (int i = 0; i < NumDigitButtons; ++i) { digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); } Button *pointButton = createButton(tr("."), SLOT(pointClicked())); Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked())); Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); Button *clearButton = createButton(tr("Clear"), SLOT(clear())); Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked())); Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked())); Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked())); Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); Button *equalButton = createButton(tr("="), SLOT(equalClicked())); //! [4] //! [5] QGridLayout *mainLayout = new QGridLayout; //! [5] //! [6] mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(display, 0, 0, 1, 6); mainLayout->addWidget(backspaceButton, 1, 0, 1, 2); mainLayout->addWidget(clearButton, 1, 2, 1, 2); mainLayout->addWidget(clearAllButton, 1, 4, 1, 2); mainLayout->addWidget(clearMemoryButton, 2, 0); mainLayout->addWidget(readMemoryButton, 3, 0); mainLayout->addWidget(setMemoryButton, 4, 0); mainLayout->addWidget(addToMemoryButton, 5, 0); for (int i = 1; i < NumDigitButtons; ++i) { int row = ((9 - i) / 3) + 2; int column = ((i - 1) % 3) + 1; mainLayout->addWidget(digitButtons[i], row, column); } mainLayout->addWidget(digitButtons[0], 5, 1); mainLayout->addWidget(pointButton, 5, 2); mainLayout->addWidget(changeSignButton, 5, 3); mainLayout->addWidget(divisionButton, 2, 4); mainLayout->addWidget(timesButton, 3, 4); mainLayout->addWidget(minusButton, 4, 4); mainLayout->addWidget(plusButton, 5, 4); mainLayout->addWidget(squareRootButton, 2, 5); mainLayout->addWidget(powerButton, 3, 5); mainLayout->addWidget(reciprocalButton, 4, 5); mainLayout->addWidget(equalButton, 5, 5); setLayout(mainLayout); setWindowTitle(tr("Calculator")); }
/******************************************************************************** * Description : Constructeur par paramètre de la calculatrice. Permet de générer une calculatrice sur mesure. * Paramètres : *parent * Type de retour : void *******************************************************************************/ Calculatrice::Calculatrice(QWidget *parent): QWidget(parent) { sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; //creation d'un objet de type QLineEdit avec par défaut la chaine de caractère 0 //cette objet représente une zone de texte qui sera utilisé comme afficheur de la calculatrice display = new QLineEdit("0"); // la zone de texte est paramétrée en lecture seule display->setReadOnly(true); // l'affichage se fera de la droite vers la gauche display->setAlignment(Qt::AlignRight); // définition de la largeur de la zone de texte à 15 display->setMaxLength(15); QFont font = display->font(); font.setPointSize(font.pointSize() + 8); display->setFont(font); //MaFenetre fenetre1; for(int i=0; i<NumDigitButtons; ++i) { digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); } Bouton *pointButton = createButton(tr("."), SLOT(pointClicked())); Bouton *changeSignButton = createButton(tr("\261"), SLOT(changeSignClicked())); Bouton *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); Bouton *clearButton = createButton(tr("Clear"), SLOT(clear())); Bouton *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); //Mes boutons Bouton *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); Bouton *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); Bouton *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); Bouton *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); Bouton *divisionButton = createButton(tr("\367"), SLOT(multiplicativeOperatorClicked())); Bouton *timesButton = createButton(tr("\327"), SLOT(multiplicativeOperatorClicked())); Bouton *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); Bouton *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); Bouton *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); Bouton *powerButton = createButton(tr("x\262"), SLOT(unaryOperatorClicked())); Bouton *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); Bouton *equalButton = createButton(tr("="), SLOT(equalClicked())); //Déclarez votre layout ici QGridLayout *mainLayout = new QGridLayout(); //Gerer le positionnement des boutons sur le layout ici //section d'affichage de la calculatrice mainLayout->addWidget(display,0,0,1,6); //bouton d'effacage d'un seul élément de la calculatrice mainLayout->addWidget(backspaceButton,1,0,1,2); //bouton effacant completement l'affichage de la calculatrice mainLayout->addWidget(clearButton,1,2,1,2); //bouton effacant l'affichage ainsi que la mémoire de la calculatrice mainLayout->addWidget(clearAllButton,1,4,1,2); //bouton effacant la mémoire de la calculatrice mainLayout->addWidget(clearMemoryButton,2,0); //bouton représentant le nombre 7 mainLayout->addWidget(digitButtons[7],2,1); //bouton représentant le nombre 8 mainLayout->addWidget(digitButtons[8],2,2); //bouton représentant le nombre 9 mainLayout->addWidget(digitButtons[9],2,3); //bouton effectuant l'operation de division mainLayout->addWidget(divisionButton,2,4); //bouton effectuant l'opération racine carrée mainLayout->addWidget(squareRootButton,2,5); //bouton affichant le contenu de la mémoire de la calculatrice mainLayout->addWidget(readMemoryButton,3,0); //bouton représentant le nombre 4 mainLayout->addWidget(digitButtons[4],3,1); //bouton représentant le nombre 5 mainLayout->addWidget(digitButtons[5],3,2); //bouton représentant le nombre 6 mainLayout->addWidget(digitButtons[6],3,3); //bouton effectuant l'opération de multiplication mainLayout->addWidget(timesButton,3,4); //bouton mettant la valeur affichée au carrée mainLayout->addWidget(powerButton,3,5); //bouton mettant la valeur affichée en mémoire de la calculatrice mainLayout->addWidget(setMemoryButton,4,0); //bouton représentant le nombre 1 mainLayout->addWidget(digitButtons[1],4,1); //bouton représentant le nombre 2 mainLayout->addWidget(digitButtons[2],4,2); //bouton représentant le nombre 3 mainLayout->addWidget(digitButtons[3],4,3); //bouton effectuant l'opération de soustraction mainLayout->addWidget(minusButton,4,4); //bouton effectuant l'opération réciproque (x -> 1/x) mainLayout->addWidget(reciprocalButton,4,5); //bouton effectuant une addition avec ce qui se trouve en mémoire de la calculatrice mainLayout->addWidget(addToMemoryButton,5,0); //bouton représentant le nombre 0 mainLayout->addWidget(digitButtons[0],5,1); //bouton permettant d'ajouter un point au nombre affiché pour faire un float mainLayout->addWidget(pointButton,5,2); //bouton effectuant un changement de signe sur le nombre affiché mainLayout->addWidget(changeSignButton,5,3); //bouton effectuant l'opération d'addition mainLayout->addWidget(plusButton,5,4); //bouton qui affiche la réponse de l'opération effectuée précédement mainLayout->addWidget(equalButton,5,5); // Ajout du layout à la fenetre principale setLayout(mainLayout); // Ajout du titre de la fenetre setWindowTitle(tr("Calculatrice")); }
SimplexMinimizer::~SimplexMinimizer() { clearMemory(); }
/// resets the size void SimplexMinimizer::resetSize(const double &size) { m_size = size; clearMemory(); initialize(m_costFunction); }