int _tmain(int argc, _TCHAR* argv[]) { time_t start_time; time_t finish_time; int eteration_count = 100000000000; // количество итераций int a = 0; // левая граница интегрирования int b = 1; // правая граница интегрирования double x; time(&start_time); double step = (double)(b - a) / eteration_count; double total = (liner(a) + liner(b))*step / 2; for (int i = 0; i < eteration_count; ++i) { x = a + i* step; total += liner(x)*step; } time(&finish_time); std::cout << "Result is: " << total << " Operation time: " << difftime(finish_time, start_time) << std::endl; return 0; }
void SelfMenu::paintEvent(QPaintEvent *e) { QPainter painter(this); // painte QPainterPath path; float h = this->height(); float w = this->width(); path.setFillRule(Qt::WindingFill); path.addRoundedRect(QRect(0, 0, w, h), 3, 3); painter.setRenderHint(QPainter::Antialiasing, true); // LinearGradient QLinearGradient liner(QPoint(0, 0), QPoint(w, h)); // 132, 216, 209 ю╤ // 47, 107, 117 д╛хо // load data ConfigureData *conf = ConfigureData::getInstance(); c1 = conf->getColorIni("color1"); c2 = conf->getColorIni("color2"); liner.setColorAt(0, c1); liner.setColorAt(1, c2); painter.fillPath(path, QBrush(liner)); painter.setPen(Qt::transparent); painter.drawPath(path); // draw some lines QList<QPoint> line1; QList<QPoint> line2; { // calc start, final point float k = h / w; int b[7]; int x1[7], x2[7]; b[0] = h /3; b[1] = h /2; b[2] = 2 * h / 3; b[3] = 4 * h / 3; b[4] = 3 * h / 2; b[5] = 5 * h / 3; b[6] = h; x1[0] = w / 6; x2[0] = w / 4; x1[1] = w / 4; x2[1] = 2 * w / 5; x1[2] = w / 4; x2[2] = 4 * w / 7; x1[3] = w / 2; x2[3] = 5 * w / 6; x1[4] = 2 * w / 3; x2[4] = 5 * w / 6; x1[5] = 3 * w / 4; x2[5] = 4 * w / 5; x1[6] = w / 4; x2[6] = 3 * w / 4; for (int i = 0; i < 7; i++) { line1 << QPoint(x1[i], - k * x1[i] + b[i]); line2 << QPoint(x2[i], - k * x2[i] + b[i]); } } for (int i = 0; i < 7; i++) { QPoint p1 = line1.at(i); QPoint p2 = line2.at(i); QLinearGradient linecolor(p1, p2); linecolor.setColorAt(0, QColor(220, 220, 220, 50)); linecolor.setColorAt(0.45, QColor(220, 220, 220, 150)); linecolor.setColorAt(0.55, QColor(220, 220, 220, 150)); linecolor.setColorAt(1, QColor(220, 220, 220, 50)); painter.setPen(QPen(QBrush(linecolor), 1)); painter.drawLine(p1, p2); } return QMenu::paintEvent(e); }