/*************************************************************************** * Copyright (C) 2006 by Goran * * gozza@darkstar * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ //nizsortwidget.cpp #include #include #include #include "nizsortwidget.h" #include NizSortWidget::NizSortWidget(QWidget* parent, const char* name, WFlags fl) : NizSortWidgetBase(parent,name,fl) {} NizSortWidget::~NizSortWidget() {} void NizSortWidget::button_clicked() { int xxx=Box1->currentItem();//index za izbor duzineNiza int dd=10;// duzina niza switch (xxx){//implemenatcija padajuceg menija case 0 : {dd=100;break;} case 1 : {dd=500;break;} case 2 : {dd=1000;break;} case 3 : {dd=3000;break;} case 4 :{dd=5000;break;} case 5:{dd =15000;break;} } pop->setText("");//resetovanje ekrana n.generishi(dd);//generisanje //Konverzija i shatmpanje char buf[3]; char* kozna=new char[dd*sizeof(int)]; strcpy(kozna,""); for(int i=0;iappend(buf); strcat(kozna," "); strcat(kozna,buf); } pop->append(kozna); /////////////////////////// gen=true; } void NizSortWidget::sortiraj() { if(gen==true){ gen=false; int xxx=Box2->currentItem();//index za izbor duzineNiza double clk=0; switch (xxx){//implemenatcija padajuceg menija case 0 : {clk=n.SelectSort()*1000;break;} case 1 : {clk=n.InsertSort()*1000;break;} case 2:{clk=n.BubbleSort()*1000;break;} case 3:{clk=n.quickSort()*1000;break;} } pop->setText(""); char baf[3];//konverzijaza time sprintf(baf,"%f",clk); rezLabel->setText(baf); char* buf1=new char [sizeof(int)*n.Duz()]; char buf[3];//konverzija za sort strcpy(buf1,""); for(int i=0;iappend(buf1); } else { rezLabel->setText(""); pop->setText("***Prvo generishite niz***"); } } #include "nizsortwidget.moc"