void barStk(int* stock, int tmn) { int tmp[stk],r,i=0; limpa(tmp,tmn); r=(rand()%tmn); showA(tmn,stock); while(i<tmn) { if (tmp[r] == 0) { tmp[r] = stock[i]; i++; r=rand()%stk; } else { r=rand()%stk; }; }; }
/** * Show the game field */ void mostrac(listP mao1,listP pl11,listP pl12,listP pl13,listP pl14,listP mao2,listP pl21,listP pl22,listP pl23,listP pl24,int* pc1,int* pc2,int* pc3,int* stock1,int* stock2,int turno) { int n=0; mvprintw(0,0,"+--------------------------------------------------------+"); mvprintw(0,3,"|Turno: %d|",turno); mvprintw(1,0,"|Jogador 1"); mvprintw(1,57,"|"); mvprintw(2,0,"|(1-5)Mao: ["); if(turno==1) { show2(mao1); } else { mvprintw(2,12,"~ ~ ~ ~ ~"); }; mvprintw(2,57,"|"); mvprintw(2,28,"]"); mvprintw(3,0,"|(10) Stock["); while ((stock1[n]==0) && (n<stk)) { n++; }; if (stock1[n] == 0) { mvprintw(3,12,"X]"); } else { if(stock1[n] == 11) mvprintw(3,12,"V]"); if(stock1[n] == 12) mvprintw(3,12,"D]"); if(stock1[n] == 13) mvprintw(3,12,"R]"); if(stock1[n] <11) mvprintw(3,12,"%d]",stock1[n]); }; mvprintw(3,57,"|"); mvprintw(4,0,"| (6)P.l.1 [");show2(pl11);mvprintw(4,57,"|"); mvprintw(5,0,"| (7)P.l.2 [");show2(pl12);mvprintw(5,57,"|"); mvprintw(6,0,"| (8)P.l.3 [");show2(pl13);mvprintw(6,57,"|"); mvprintw(7,0,"| (9)P.l.4 [");show2(pl14);mvprintw(7,57,"|"); mvprintw(8,0,"+--------------------------------------------------------+"); mvprintw(9,3,"(d1)P.c.1 [");showA(13,pc1); mvprintw(10,3,"(d2)P.c.2 [");showA(13,pc2); mvprintw(11,3,"(d3)P.c.3 [");showA(13,pc3); mvprintw(12,0,"+--------------------------------------------------------+"); mvprintw(13,0,"| (9)P.l.4 [");show2(pl24);mvprintw(13,57,"|"); mvprintw(14,0,"| (8)P.l.3 [");show2(pl23);mvprintw(14,57,"|"); mvprintw(15,0,"| (7)P.l.2 [");show2(pl22);mvprintw(15,57,"|"); mvprintw(16,0,"| (6)P.l.1 [");show2(pl21);mvprintw(16,57,"|"); n=0; mvprintw(17,0,"|(10) Stock["); while ((stock2[n]==0) && (n<stk)) { n++; }; if (stock2[n] == 0) { mvprintw(17,12,"X]"); } else { if(stock2[n] == 11) mvprintw(17,12,"V]"); if(stock2[n] == 12) mvprintw(17,12,"D]"); if(stock2[n] == 13) mvprintw(17,12,"R]"); if((stock2[n] != 11) &&(stock2[n] != 12)&&(stock2[n] != 13)) mvprintw(17,12,"%d]",stock2[n]); }; mvprintw(17,57,"|"); mvprintw(18,0,"|(1-5)Mao: ["); if(turno==2) { show2(mao2); } else { mvprintw(18,12,"~ ~ ~ ~ ~"); }; mvprintw(18,57,"|"); mvprintw(18,28,"]"); mvprintw(19,0,"|Jogador 2");mvprintw(19,57,"|"); mvprintw(20,0,"+--------------------------------------------------------+"); }
Menu::Menu(QWidget *parent) : defaultScreenWidth(480), defaultScreenHeight(800), QMainWindow(parent) { setAttribute(Qt::WA_DeleteOnClose); central = new QWidget(this); central->setObjectName("central"); windowTitle = new QLabel; windowTitle->setScaledContents(true); AButton = new QPushButton(tr("Сложение")); AButton->setFocusPolicy(Qt::NoFocus); connect(AButton, SIGNAL(clicked()), this, SLOT(showA())); BButton = new QPushButton(tr("Вычитание")); BButton->setFocusPolicy(Qt::NoFocus); connect(BButton, SIGNAL(clicked()), this, SLOT(showB())); CButton = new QPushButton(tr("Умножение на число")); CButton->setFocusPolicy(Qt::NoFocus); connect(CButton, SIGNAL(clicked()), this, SLOT(showC())); DButton = new QPushButton(tr("Умножение")); DButton->setFocusPolicy(Qt::NoFocus); connect(DButton, SIGNAL(clicked()), this, SLOT(showD())); EButton = new QPushButton(tr("Транспонирование")); EButton->setFocusPolicy(Qt::NoFocus); connect(EButton, SIGNAL(clicked()), this, SLOT(showE())); FButton = new QPushButton(tr("Определитель")); FButton->setFocusPolicy(Qt::NoFocus); connect(FButton, SIGNAL(clicked()), this, SLOT(showF())); GButton = new QPushButton(tr("Возведение в степень")); GButton->setFocusPolicy(Qt::NoFocus); connect(GButton, SIGNAL(clicked()), this, SLOT(showG())); HButton = new QPushButton(tr("Обратная матрица")); HButton->setFocusPolicy(Qt::NoFocus); connect(HButton, SIGNAL(clicked()), this, SLOT(showH())); IButton = new QPushButton(tr("След")); IButton->setFocusPolicy(Qt::NoFocus); connect(IButton, SIGNAL(clicked()), this, SLOT(showI())); JButton = new QPushButton(tr("Треугольный вид")); JButton->setFocusPolicy(Qt::NoFocus); connect(JButton, SIGNAL(clicked()), this, SLOT(showJ())); KButton = new QPushButton(tr("Ранг")); KButton->setFocusPolicy(Qt::NoFocus); connect(KButton, SIGNAL(clicked()), this, SLOT(showK())); LButton = new QPushButton(tr("Определенность матрицы")); LButton->setFocusPolicy(Qt::NoFocus); connect(LButton, SIGNAL(clicked()), this, SLOT(showL())); settingsButton = new QPushButton(tr("Настройки")); settingsButton->setFocusPolicy(Qt::NoFocus); connect(settingsButton, SIGNAL(clicked()), this, SLOT(showSettings())); scaling(); designInit(); sizeInit(); init(); setCentralWidget(central); setWindowTitle(tr("Матричный калькулятор++")); }