int main() { int i, vysledek; /* inicializace poli */ for (i = 0; i < 10; i++) { x[i] = i + 1; a[i] = (i + 1) * 2; b[i] = (i + 1) * (i + 1); } x[5] = 0; /* nulovy delitel */ vysledek = nasobeni(); if (vysledek == 0) printf("Nulovy delitel\n"); else { /* tisk pole */ for (i = 0; i < 10; i++) printf("%d ", a[i]); } return 0; }
int main() { /** Testovani souctu */ // test 1 - celych cisel SHOULD_BE_EQUAL_FLOAT(122.0+105.0,sucet(122.0,105.0),"soucet_1"); // test 2 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT(36514.515+3652.525, sucet(36514.515,3652.525),"soucet_2"); // test 3 - desetinnych cisel s vetsi presnosti SHOULD_BE_EQUAL_FLOAT(9.8+3.1, sucet(9.8,3.1),"soucet_3"); // test 4 - zapornych cisel SHOULD_BE_EQUAL_FLOAT(-1.5811111+6.5252525, sucet(-1.5811111,6.5252525),"soucet_4"); /** Testovani rozdilu */ // test 5 - celych cisel SHOULD_BE_EQUAL_FLOAT(55.0-20.0, rozdil(55.0,20.0), "rozdil_5"); // test 6 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT( 358.49-258.4, rozdil(358.49,258.4),"rozdil_6"); // test 7 - desetinnych cisel s vetsi presnosti SHOULD_BE_EQUAL_FLOAT(256.12357-128.999999, rozdil(256.12357,128.999999),"rozdil_7"); // test 8 - zapornych desetinnych cisel SHOULD_BE_EQUAL_FLOAT(-2.555555-(-3.595959), rozdil(-2.555555,-3.595959), "rozdil_8"); /** Testovani nasobeni */ // test 9 - celych cisel SHOULD_BE_EQUAL_FLOAT(11.0*3.0, nasobeni(11.0,3.0),"nasobeni_9"); // test 10 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT(35.555*211.652, nasobeni(35.555,211.652),"nasobeni_10"); // test 11 - nasobeni nulou SHOULD_BE_EQUAL_FLOAT(5.5*0.0, nasobeni(5.5,0.0),"nasobeni_11"); // test 12 - nasobeni zapornym cislem SHOULD_BE_EQUAL_FLOAT(36.56*(-4.123), nasobeni(36.56,-4.123),"nasobeni_12"); /** Testovani podilu */ // test 13 - celych cisel SHOULD_BE_EQUAL_FLOAT( 8.0/4.0, podil(8.0,4.0),"podil_13"); // test 14 - desetinnych cisel SHOULD_BE_EQUAL_FLOAT(64.5/28.244, podil(64.5,28.244),"podil_14"); // test 15 - zapornych cisel SHOULD_BE_EQUAL_FLOAT(-96.2/16.5, podil(-96.2,16.5),"podil_15"); // test 16 - podil nulou SHOULD_BE_EQUAL_INF(45.136/0.0,podil(45.136,0.0),"podil_16"); // using isnan() function /** Testovani mocniny */ // test 17 - umocneni celeho cisla SHOULD_BE_EQUAL_FLOAT(pow(5.0,3.0), my_pow(5.0,3.0),"mocnina_17"); // test 18 - umocneni desetinneho cisla SHOULD_BE_EQUAL_FLOAT(pow(25.684,6.0), my_pow(25.684,6),"mocnina_18"); // test 19 - umocneni zapornym cislem SHOULD_BE_EQUAL_NAN(NAN, my_pow(11.6545,-8),"mocnina_19"); // test 20 - umocneni nulou SHOULD_BE_EQUAL_FLOAT(pow(78.1111,0.0), my_pow(78.1111,0),"mocnina_20"); /** Testovani druhe odmocniny */ // test 21 - odmocneni celeho cisla SHOULD_BE_EQUAL_FLOAT(pow(64.0,1/2.0), my_sqrt(64.0), "odmocnina_21"); // test 22 - odmocneni desetinneho cisla SHOULD_BE_EQUAL_FLOAT(pow(235.154787,1/2.0), my_sqrt(235.154787),"odmocnina_22"); // test 23 - odmocneni zaporneho cisla SHOULD_BE_EQUAL_NAN(pow(-81.154787,1/2.0),my_sqrt(-81.154787),"odmocnina_23"); // test 24 - odmocneni nuly SHOULD_BE_EQUAL_FLOAT(pow(0,1/2.0),my_sqrt(0),"odmocnina_24"); /** Testovani arcus sinu */ // test 25 - krajnich hodnot Df SHOULD_BE_EQUAL_FLOAT(asin(1.0), my_asin(1.0),"arcus_sinus_25"); // test 26 - krajnich hodnot Df SHOULD_BE_EQUAL_FLOAT(asin(-1.0), my_asin(-1.0),"arcus_sinus_26"); // test 27 - hodnot z intervalu (-1;1) SHOULD_BE_EQUAL_FLOAT(asin(0.56), my_asin(0.56),"arcus_sinus_27"); // test 28 - hodnot z intervalu (-1;-0.9) a (0.9;1) SHOULD_BE_EQUAL_FLOAT(asin(-0.96), my_asin(-0.96),"arcus_sinus_28"); //test 29 - hodnot mimo definicni obor SHOULD_BE_EQUAL_NAN(NAN,my_asin(-2.56),"arcus_sinus_29"); /** Testovani faktorialu */ // test 30 - kladneho celeho cisla SHOULD_BE_EQUAL_FACT(120.0,factorial(5),"factorial_33"); // test 31 - kladneho celeho cisla SHOULD_BE_EQUAL_FACT(40320.0,factorial(8),"factorial_34"); //test 32 - zaporneho cisla SHOULD_BE_EQUAL_NAN(NAN,factorial(-6),"factorial_35"); // test 33 - cisla s vysledkem nad limit hodnot promenne integer SHOULD_BE_EQUAL_NAN(NAN,factorial(100.0),"factorial_36"); // test 34 - desetinneho cisla SHOULD_BE_EQUAL_NAN(NAN,factorial(29.99),"factorial_37"); /** Testovani absolutni hodnoty */ // test 37 - kladneho celeho cisla SHOULD_BE_EQUAL_FLOAT(fabs(11.0), my_abs(11.0),"my_abs_38"); // test 38 - zaporneho cisla SHOULD_BE_EQUAL_FLOAT(fabs(-222.0), my_abs(-222.0),"my_abs_39"); // test 39 - desetinneho cisla SHOULD_BE_EQUAL_FLOAT(fabs(-55.666), my_abs(-55.666),"my_abs_40"); // test 40 - nuly SHOULD_BE_EQUAL_FLOAT(fabs(0), my_abs(0),"my_abs_41"); printf("\nTest failed: %d\n", errors); printf("Test passed: %d\n",passed); return 0; }
/** * @brief Sestaveni celeho okna kalkulaci a pozicovani objektu */ MainWindow::MainWindow(QWidget *parent) : /* nize je napozicovany kazdy jednotlivy objekt kalkulacky, a take spusteni signalu */ QMainWindow(parent) { this->setWindowTitle("Kalkulačka Vořežpruti"); lcd = new QLCDNumber(10, this); lcd -> setGeometry(QRect(QPoint(50,50), QSize(200, 50))); clear_button = new QPushButton("C",this); clear_button -> setGeometry(QRect(QPoint(200,300), QSize(50,50))); connect(clear_button, SIGNAL(released()), this, SLOT(clear())); napoveda_button = new QPushButton("?", this); napoveda_button -> setGeometry(QRect(QPoint(125,400), QSize(50,50))); connect(napoveda_button, SIGNAL(released()), this, SLOT(napoveda())); rovno_button = new QPushButton("=", this); rovno_button -> setGeometry(QRect(QPoint(50,350), QSize(200,50))); connect(rovno_button, SIGNAL(released()), this, SLOT(rovno())); scitani_button = new QPushButton("+", this); scitani_button -> setGeometry(QRect(QPoint(50,100), QSize(50,50))); connect(scitani_button, SIGNAL(released()), this, SLOT(scitani())); nasobeni_button = new QPushButton("x", this); nasobeni_button -> setGeometry(QRect(QPoint(150,100), QSize(50,50))); connect(nasobeni_button, SIGNAL(released()), this, SLOT(nasobeni())); deleni_button = new QPushButton("/", this); deleni_button -> setGeometry(QRect(QPoint(200,100), QSize(50,50))); connect(deleni_button, SIGNAL(released()), this, SLOT(deleni())); odcitani_button = new QPushButton("-", this); odcitani_button -> setGeometry(QRect(QPoint(100,100), QSize(50,50))); connect(odcitani_button, SIGNAL(released()), this, SLOT(odcitani())); nula_button = new QPushButton("0", this); nula_button -> setGeometry(QRect(QPoint(50,300), QSize(50,50))); connect(nula_button, SIGNAL(released()), this, SLOT(nula())); jedna_button = new QPushButton("1", this); jedna_button -> setGeometry(QRect(QPoint(50,250), QSize(50,50))); connect(jedna_button, SIGNAL(released()), this, SLOT(jedna())); dva_button = new QPushButton("2", this); dva_button -> setGeometry(QRect(QPoint(100,250), QSize(50,50))); connect(dva_button, SIGNAL(released()), this, SLOT(dva())); tri_button = new QPushButton("3", this); tri_button -> setGeometry(QRect(QPoint(150,250), QSize(50,50))); connect(tri_button, SIGNAL(released()), this, SLOT(tri())); ctyri_button = new QPushButton("4", this); ctyri_button -> setGeometry(QRect(QPoint(50,200), QSize(50,50))); connect(ctyri_button, SIGNAL(released()), this, SLOT(ctyri())); pet_button = new QPushButton("5", this); pet_button -> setGeometry(QRect(QPoint(100,200), QSize(50,50))); connect(pet_button, SIGNAL(released()), this, SLOT(pet())); sest_button = new QPushButton("6", this); sest_button -> setGeometry(QRect(QPoint(150,200), QSize(50,50))); connect(sest_button, SIGNAL(released()), this, SLOT(sest())); sedm_button = new QPushButton("7", this); sedm_button -> setGeometry(QRect(QPoint(50,150), QSize(50,50))); connect(sedm_button, SIGNAL(released()), this, SLOT(sedm())); osm_button = new QPushButton("8", this); osm_button -> setGeometry(QRect(QPoint(100,150), QSize(50,50))); connect(osm_button, SIGNAL(released()), this, SLOT(osm())); devet_button = new QPushButton("9", this); devet_button -> setGeometry(QRect(QPoint(150,150), QSize(50,50))); connect(devet_button, SIGNAL(released()), this, SLOT(devet())); tecka_button = new QPushButton(".", this); tecka_button -> setGeometry(QRect(QPoint(100,300), QSize(50,50))); connect(tecka_button, SIGNAL(released()), this, SLOT(tecka())); faktorial_button = new QPushButton("!", this); faktorial_button -> setGeometry(QRect(QPoint(200,150), QSize(50,50))); connect(faktorial_button, SIGNAL(released()), this, SLOT(faktorial())); mocnina_button = new QPushButton("^", this); mocnina_button -> setGeometry(QRect(QPoint(200,200), QSize(50,50))); connect(mocnina_button, SIGNAL(released()), this, SLOT(mocnina())); odmocnina_button = new QPushButton("sqrt", this); odmocnina_button -> setGeometry(QRect(QPoint(200,250), QSize(50,50))); connect(odmocnina_button, SIGNAL(released()), this, SLOT(odmocnina())); negate_button = new QPushButton("+/-", this); negate_button -> setGeometry(QRect(QPoint(150,300), QSize(50,50))); connect(negate_button, SIGNAL(released()), this, SLOT(negate())); }