Гистограммы и диаграммы в Visual C++

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by Mello^_^, 23 Jan 2012.

  1. Mello^_^

    Mello^_^ New Member

    Joined:
    4 Dec 2011
    Messages:
    8
    Likes Received:
    0
    Reputations:
    0
    Облазил весь интернет, но так и не нашел реализацию диаграмм в Visual C++, хотя сейчас мне это очень нужно.Нужен любой простейший пример создания гистограммы.
     
  2. cheater_man

    cheater_man Member

    Joined:
    13 Nov 2009
    Messages:
    651
    Likes Received:
    44
    Reputations:
    7
    Помоему только в ручную, Rectangle, Ellipse, Line и т.д.
     
  3. GRRRL Power

    GRRRL Power Elder - Старейшина

    Joined:
    13 Jul 2010
    Messages:
    823
    Likes Received:
    185
    Reputations:
    84
    В Вижал С++ можно подключить какой-нибудь QT, который наверняка уже умеет строить гистогрыммы. Если надо все сделать самому и с нуля, то да, GDI или GDI+ и вперед.
     
  4. Mello^_^

    Mello^_^ New Member

    Joined:
    4 Dec 2011
    Messages:
    8
    Likes Received:
    0
    Reputations:
    0
    Ну мне нужно, чтобы гистограма была на вводимых пользовательских данных, то есть вручную мне ничего вырисовывать не надо, и насколько я понял в консольном приложении мне это сделать не получится
     
  5. lamer811

    lamer811 Elder - Старейшина

    Joined:
    8 Nov 2009
    Messages:
    130
    Likes Received:
    39
    Reputations:
    12
    В далекие времена, когда я был студентом 3его курса и кодил на С++
    Я использовал компонент: TChart
    Проблема в том, что этот компонент я юзал в C++ Builder 6.0

    Нет, ничего не возможного, в свое время как только я не извращался...
     
  6. St0nX

    St0nX Elder - Старейшина

    Joined:
    19 May 2007
    Messages:
    257
    Likes Received:
    46
    Reputations:
    0
    http://qwt.sourceforge.net/
     
  7. Mello^_^

    Mello^_^ New Member

    Joined:
    4 Dec 2011
    Messages:
    8
    Likes Received:
    0
    Reputations:
    0
    Вот по этой программе должна создаватся гистограмма:


    #include "stdafx.h"
    class CMainWnd : public CFrameWnd
    {
    public:
    CMainWnd () ;
    afx_msg int OnPaintO;
    afx_msg int OnSizeCUINT, int, int);
    afx_msg int OnCreate(LPCREATESTRUCT cs);
    afx_msg void OnAboutO;
    afx_msg void OnBarData ();
    afx_msg void OnExitO;
    DECLARE_MESSAGE_MAP ()
    };
    class CTheApp : public CWinApp
    {
    public:
    virtual BOOL Initlnstance (); };
    class CBarDataDialog : public CDialog
    < public:
    CBarDataDialog (CWnd* pParentWnd=NULL)
    : CDialog ("BarDlgBox", pParentWnd)
    { }
    virtual void OnOK(); };

    #define IDM_ABOUT 10 #define IDM_INPUT 20
    #define IDM_EXIT 30 #define DM_TITLE 300 #define DM_XLABEL 301

    #define DM_YLABEL 302 #define DM_P1 303
    #define DM_P2 304 #define DM_P3 305 Idefine DM_P4 306
    #define DM_P5 307
    #define DM_P6 308
    #define DM_P7 309
    #define DM_P8 310
    f define DM_P9 311
    #define DM_P10 312
    #include "resource. h"
    #include "barchartr .h"

    #define APSTODIO_READONLY_SYMBOLS
    //////////////////////////////////////////////////////
    #define APSTODIO_HIDDEN_SYMBOLS
    #include "windows.h"
    #undef APSTUDIO_HIDDEN_SYMBOLS
    #include "afxres.h"
    //////////////////////////////////////////////////////
    #undef APSTUDIO_READONLY_SYMBOLS
    ////////////////////////////////////////////////////
    // Ресурсы для английского (США) языка
    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
    #ifdef _WIN32
    LANGUAGE LANG^ENGLISH, SUBLANG_ENGLISH_US tpragma code_page(1252)
    #endif // WIN32
    //////////////////////////////////////////////////////
    CTEXT "By William H. Murray and Chris H. Pappas",
    -1,28/ 28,144, 8
    CTEXT "(c)Copyright 1998",-1, 68,38, 83, 8 DEFPUSH
    84, 55, 32, 14, WS_GROUP
    END
    BARDLGBOX DIALOG DISCARDABLE 42,65526,223,209
    STYLE WS_POPUP I WS_CAPTION
    CAPTION "Bar Chart Data"
    BEGIN
    GROUPBOX "Bar Chart Title:",100, 5, 11,212,89,WSJT
    GROUPBOX "Bar Chart Heights", 101, 5, 105, 212, 90
    LTEXT "Title:", -1,43,35,28,8, NOT WS_GROUP
    EDITTEXT DM_TITLE, 75,30,137,12
    LTEXT "x-axis label:",-1,15,55, 55,8, NOT WS_GROUP
    EDITTEXT DM_XLABEL, 75,50,135, 12
    LTEXT "y-axis label:",-1,15, 75, 60,8,
    EDITTEXT.DM_YLABEL, 75,70,135,12
    LTEXT "Bar #1 ", -1,45,125, 40, 8, NOT W
    LTEXT "Bar #2 ", -1,45,140, 40, 8, NOT W
    LTEXT "Bar #3 ", -1,45,155, 40, 8, NOT W
    LTEXT "Bar #4 ", -1,45,170, 40, 8, NOT W
    LTEXT "Bar #5 ", -1,45,185, 40, 8, NOT W
    LTEXT "Bar #6 ", -1,130, 125> 40,8, NOT WS_GROOP
    LTEXT "Bar #7 ", -1,130, 140, 40,8, NOT WS_GROUP
    LTEXT "Bar #8 ", -1,130, 155, 40,8, NOT WS_GROUP
    LTEXT "Bar #9 ", -1,130, 170,40,8, NOT WS_GROUP
    LTEXT "Bar #10:",-1,130, 185, 45,8, NOT WS_GROUP
    EDITTEXT DM_P1, 90,120, 30,12
    EDITTEXT DM_P2, 90,135,30, 12
    EDITTEXT DM_P3, 90,150, 30,12
    EDITTEXT DM_P4, 90,165,30, 12
    EDITTEXT DM_P4, 90,165,30, 12
    EDITTEXT DM_P5, 90,180, 30,12
    EDITTEXT DM_P6, 180, 120, 30,12
    EDITTEXT DM_P7, 180, 135, 30,12
    EDITTEXT DM_P8, 180, 150, 30,12
    EDITTEXT DM_P9, 180, 165,30,12
    EDITTEXT DM_P10, 180, 180, 30,12
    PUSHBUTTON "ОК", IDOK, 54,195,24,14
    END
    PUSHBUTTON "Cancel", IDCANCEL, 124, 195
    #ifdef APSTUDIO_INVOKED
    ///////////////////////////////////////
    1 TEXTINCLUDE DISCARDABLE BEGIN
    "resource.h\0" END
    2 TEXTINCLUDE DISCARDABLE BEGIN
    #define APSTUDIO_HIDDEN_SYMBOLS\r\n"
    #include ""windows.h""\r\n"
    #undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "#include ""afxres.h""\r\n"
    "\0" END
    3 TEXTINCLUDE DISCARDABLE BEGIN
    "\r\n"
    "\0" END
    #endif // APSTUDIO_INVOKED
    #endif // Ресурсы для английского (США) языка

    //
    // barchart.cpp
    // Построение гистограмм.
    //
    //
    #include <afxwin.h>
    #include <string.h>
    #include <math.h>
    #include <stdlib.h>
    #include "barchartr.h" // идентификаторы ресурсов
    #include "barchart.h"
    #define maxnumbar
    char szTString[80] = "(barchart title area)";
    char szXString[80]= "x-axis label";
    char szYString[80] = "y-axis label";
    int iBarSize[maxnumbar] = {20,10, 40, 50};
    int m_cxClient, m_cyClient;
    CTheApp theApp;
    CMainWnd::CMainWnd() {
    Create(AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,LoadCursor(NULL,
    IDC_CROSS),
    (HBRDSH)'GetStockObject (WHITE_BRUSH) , NULL) , "Bar Chart Application
    with the MFC ", WS_OVERLAPPEDWINDOW, rectDefault, NULL, "BarMenu");
    }
    void CMainWnd::OnSize(OINT, int x, int y) (
    m_cxClient = x;
    m_cyClient = y; )
    void CMainWnd::OnPaint()
    {
    CPaintDC dc(this);
    static DWORD dwColorflO] = {
    CPaintDC dc(this);
    static DWORD dwColorflO] =
    {
    RGB(0,0, d), // черный
    RGB(245,0, 0), // красный
    RGB(0,245,0), // зеленый
    RGB(0,0, 245), // синий
    RGB(245,245, 0), // желтый
    RGB(245,0, 245), //пурпурный
    RGB(0,245,245), // голубой
    RGB(0,80,80), // голубовато-серый
    RGB(80,80,80), // темно-серый
    RGB(245, 245, 245)};// белый
    CFont newfont;
    CFont* oldfont;
    CBrush newbrush;
    CBrush* oldbrush;
    int i, iNBars, iBarWidth, iBarMax;
    int ilenMaxLabel;
    int xl,x2,yl,y2;
    int iBarSizeScaled[maxnumbar] ; char sbuffer[10],*strptr;
    iNBars = 0;
    for(i=0;i < maxnumbar; i++){ iffiBarSize != 0) iNBars++;
    }
    iBarWidth = 400/iNBars;
    // Поиск столбца, имеющего максимальную высоту
    iBarMax = iBarSize[0]; for(i=. 0; i < iNBars; i++)
    if(iBarMax < iBarSize)iBarMax = iBarSize ;
    // Преобразование максимального значения по у встроку
    strptr = _itoa(iBarMax, sbuffer, 10); ilenMaxLabel = strlen(sbuf
    // Масштабирование столбцов в массиве.
    // Максимальная высота столбца — 270.
    for(i= 0; i < iNBars; i++)
    iBarSizeScaled = iBarSize* (270/iBarMax);
    // Задание режима отображения
    //и создание области просмотра
    dc.SetMapMode(MM_ISOTROPIC) ;
    dc.SetWindowExt(640,400);
    dc.SetViewportExt(m_cxClient, m_cyClient);
    dc.SetViewportOrg(0, 0) ;
    // Выводтекставокно, если для него хватает места if(m_cxClient > 200)
    newfont.CreateFont(12,12, О, О, FW_BOLD,
    FALSE, FALSE, FALSE, OEM_CHARSET, OOT_DEFAULT_PRECIS,
    CLIP_DEFAULT_PRECIS, DEFAOLT_QUALITY, VARIABLE_PITCH | FF_ROMAN,
    "Roman");
    oldfont = dc.SelectObject(Snewfont); dc.TextOut((300-
    (strlen(szTString)*10/2) ) ,
    15,szTString, strlen(szTString));
    dc.TextOut((300-(strlen(szXString)* 10/2)) ,
    365,szXString, strlen(szXString));
    dc.TextOut((90- ilenMaxLabel*12), 70,strptr, ilenMaxLabel); //
    удалениеобъекташрифтаdc.SelectObject(oldfont); newfont.DeleteObj
    newfont.CreateFont(12,12,900,900,FW_BOLD,
    FALSE, FALSE,.FALSE, OEM_CHARSET, OUT_DEFAULT_PRECIS,
    CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_ROMAN,
    "Roman");
    oldfont = dc.SelectObject(Snewfont) ;
    dc.TextOut(50,200+ (strlen(szXString)*10/2), szYString,
    strlen(szYString));
    // удаление объекта шрифта
    dc.SelectObject(oldfont) ;
    newfont.DeleteObj ect() ;
    }
    // Рисование осей координат
    dc.MoveTo(99,49);
    dc.LineTo(99,350);
    dc.LineTo(500, 350);
    dc.MoveTo(99,350);
    // Начальные значения
    xl = 100;
    yl = 350;
    x2 = xl + iBarWidth;
    // Рисование столбцов
    for(i=0;i < iNBars; i++) {
    newbrush.CreateSolidBrush(dwColor),
    oldbrush = dc.SelectObject(Snewbrush)
    y2 = 350 - iBarSizeScaled;
    dc.Rectangle(xl,yl,x2, y2);
    xl = x2;
    x2 += IBarWidth;
    // удаление кисти
    dc.SelectObject(oldbrush);
    newbrush.DeleteObject(); }
    int CMainWnd::OnCreate(LPCREATESTRUCT)
    {
    UpdateWindow();
    return (0);
    }
    void CMainWnd::OnAbout()
    {
    CDialog about("AboutDlgBox", this);
    about.DoModal();
    }
    void CBarDataDialog::OnOK()
    {
    GetDlgltemText(DMJTITLE, szTString, 80);
    GetDlgltemText(DM_XLABEL, szXString, 80);
    GetDlgltemText(DM_YLABEL, szYString, 80);
    iBarSize[0] = GetDlgltemlnt(DM_P1, NULL, 0)
    iBarSize[l]= GetDlgltemlnt(DM_P2, NULL, 0)
    iBarSize[2] = GetDlgltemlnt(DM_P3, NULL, 0)
    iBarSize[3] = GetDlgltemlnt(DM_P4, NULL, 0)
    iBarSize[4] = GetDlgltemlnt(DM_P5, NULL, 0)
    iBarSize[5] = GetDlgltemlnt(DM_P6, NULL, 0)
    iBarSize[6]= GetDlgltemlnt(DM_P7, NULL, 0)
    iBarSize[7] = GetDlgltemlnt(DM_P8, NULL, 0)
    iBarSize[8] = GetDlgltemlnt(DM_P9, NULL, 0)
    iBarSize[9]= GetDlgltemlnt(DM_P10, NULL, 0)
    CDialog: :OnOK();
    }
    void CMainWnd::OnBarData()
    {
    CBarDataDialog dlgBarData(this); if(dlgBarData.DoModal{) == IDOK)
    InvalidateRect(NULL, TRUE); UpdateWindow(); )
    };
    void CMainWnd::OnExit()
    {
    DestroyWindowO ;
    }
     
  8. Mello^_^

    Mello^_^ New Member

    Joined:
    4 Dec 2011
    Messages:
    8
    Likes Received:
    0
    Reputations:
    0
    Точнее мой помт выше это пример диаграммы созданой в MFC а вот прога по которой я должен писать диаграмму:
    #pragma warning(push)
    #pragma warning(disable: 4101 4390)
    #pragma warning(pop)
    #include "stdio.h"
    #include "iostream.h"
    #include "conio.h"
    #include "stdlib.h"
    #include "math.h"
    #include <iomanip.h>

    int temp ()

    {

    double x2, x1, x3, x4, y, c1, c2, c3, c4, d1, d2, d3, d4;
    double tbaz1, tbaz2, tbaz3, tbaz4;
    double tcep1, tcep2, tcep3, tcep4;
    double tpr1, tpr2, tpr3, tpr4;
    double tprc1, tprc2, tprc3, tprc4;

    system("cls");



    while(1)
    {
    cout << "Vvedite kolichestvo realizovanoi produkzii za sentjabr: \n";
    cout << setw(2) << setprecision(2);
    cin >> y ;
    if (y<0)
    {
    cout <<" \n Vvod otricatelnyh chisel nedopustim";
    continue;
    }
    if (y>0)


    cout << " Vvedite kolichestvo realizovanoi produkzii za oktjabr: \n";
    cout << setw(2) << setprecision(2);
    cin >> x1 ;
    if (x1<0)
    {
    cout <<" \n Vvod otricatelnyh chisel nedopustim";
    continue;
    }
    if (x1>0)


    cout <<" Vvedite kolichestvo realizovanoi produkzii za noyabr: \n";
    cout << setw(2)<< setprecision(2);
    cin >> x2 ;
    if (x2<0)
    {
    cout <<" \n Vvod otricatelnyh chisel nedopustim";
    continue;
    }
    if (x2>0)

    cout <<" Vvedite kolichestvo realizovanoi produkzii za dekabr: \n";
    cout << setw(2)<< setprecision(2);
    cin >> x3 ;
    if (x3<0)
    {
    cout <<" \n Vvod otricatelnyh chisel nedopustim";
    continue;
    }
    if (x3>0)

    cout << " Vvedite kolichestvo realizovanoi produkzii za yanvar: \n" << cout << setw(2)<< setprecision(2);
    cin >> x4 ;

    if (x4<0)
    {

    cout <<" \n Vvod otricatelnyh chisel nedopustim";
    continue;
    }
    if (x4>0)
    goto j;
    }


    j:;
    system("cls");
    cout << " nahodim bazisnyi absolyutnyi prirost: \n";
    c1=x1-y, c2=x2-y, c3=x3-y, c4=x4-y;
    cout << setiosflags(ios::scientific);
    cout << "Rezultat:" << "\n" << c1 << setw(3)<< setprecision(1) << "\n" << c2 << setw(3)<< setprecision(1) <<"\n" << c3 << setw(3)<< setprecision(1) <<"\n" << c4 << setw(3)<< setprecision(1)<< "\n" ;
    getchar();


    cout << " nahodim cepnoi absolyutnui prirost: \n";
    d1=x1-y, d2=x2-x1,d3=x3-x2, d4=x4-x3;
    cout << setiosflags(ios::scientific);
    cout << "Rezultat:" << "\n" << d1 <<setw(3)<< setprecision(1) << "\n" << d2<<setw(3)<< setprecision(1) << "\n" << d3 <<setw(3)<< setprecision(1) << "\n" << d4 <<setw(3)<< setprecision(1) << "\n" ;
    getchar();


    system("cls");

    cout << " nahodim bazisnyi temp rosta: \n";
    tbaz1=(x1/y)*100, tbaz2=(x2/y)*100, tbaz3=(x3/y)*100, tbaz4=(x4/y)*100;
    cout << setiosflags(ios::scientific);
    cout << "Rezultat:" << "\n" << tbaz1 <<setw(3)<< setprecision(1) << "%" << "\n" << tbaz2 << "%" <<setw(3)<< setprecision(1) << "\n" << tbaz3 <<setw(3)<< setprecision(1) << "%" << "\n" << tbaz4 <<setw(3)<< setprecision(1) << "%" << "\n" ;
    getchar();
    system("stop");
    cout << " nahodim cepnoi temp rosta: \n";
    tcep1=(x1/y)*100, tcep2=(x2/x1)*100, tcep3=(x3/x2)*100, tcep4=(x4/x3)*100;
    cout << setiosflags(ios::scientific);
    cout << "Rezultat:" << "\n" << tcep1 <<setw(3)<< setprecision(1) << "%" << "\n" << tcep2 <<setw(3)<< setprecision(1) << "%" << "\n" << tcep3 <<setw(3)<< setprecision(1) << "%" << "\n" << tcep4 <<setw(3)<< setprecision(1) << "%" << "\n";
    getchar();

    system("cls");

    cout << " nahodim bazisnui temp prirosta: \n";
    tpr1= tbaz1-100, tpr2=tbaz2-100, tpr3=tbaz3-100, tpr4=tbaz4-100;
    cout << setiosflags(ios::scientific);
    cout << "Rezultat:" << "\n" << tpr1 <<setw(3)<< setprecision(1) << "%" << "\n" << tpr2 <<setw(3)<< setprecision(1) << "%" << "\n" << tpr3 <<setw(3)<< setprecision(1) << "%" << "\n" << tpr4 <<setw(3)<< setprecision(1) << "%" << "\n" ;
    getchar();

    cout << " nahodim cepnoi temp prirosta: \n";
    tprc1= tcep1-100, tprc2=tcep2-100, tprc3=tcep3-100, tprc4=tcep4-100;
    cout << setiosflags(ios::scientific);
    cout << "Rezultat:" << "\n" << tprc1 <<setw(3)<< setprecision(1) << "%" << "\n" << tprc2 <<setw(3)<< setprecision(1) << "%" << "\n" << tprc3 <<setw(3)<< setprecision(1) << "%" << "\n" << tprc4 <<setw(3)<< setprecision(1) << "%" << "\n" ;
    getchar();


    double aproc;
    system("cls");
    cout << " nahodim absolyutnoe znachenie odnogo procenta prirosta: \n";
    aproc= d1/tprc1;
    cout << setiosflags(ios::scientific);
    cout <<setw(1)<< setprecision(3);
    cout <<"Rezultat:" << "\n" << aproc;

    getchar();

    system("cls");
    double midt;
    int n;
    n=5;
    cout << "sredniy temp rosta: \n ";


    midt=pow(n-1,sqrt(d1*d2*d3*d4));
    cout << setiosflags(ios::scientific);
    cout << setw(3)<< setprecision(2);
    cout <<"Rezultat:" << "\n" << midt ;
    getchar();
    return 0;
    }


    int stat()
    {


    char name1[64], name2[64], name3[64];
    float tovb1, tovb2, tovb3;
    float tovt1, tovt2, tovt3;
    float iq1, iq2, iq3;
    float ip1, ip2, ip3;
    float sum1, sum2;
    float dellall;
    float indcen;
    float indtov;
    float del1, del2, del3;
    system ("cls");
    printf("1. Vvedite nazvanie produkta \n");
    scanf("%s", name1);
    printf("1. Vvedite bazisnyi tovarooborot \n");
    scanf("%f", &tovb1);
    printf("1. Vvedite tekushyi tovarooborot \n");
    scanf("%f", &tovt1);
    printf("1. Vvedite indeks obyema produkcii \n");
    scanf("%f", &iq1);
    printf("1. Vvedite indvidualnyi indeks \n");
    scanf("%f", &ip1);

    printf("2. Vvedite nazvanie produkta \n");
    scanf("%s", name2);
    printf("2. Vvedite bazisnyi tovarooborot \n");
    scanf("%f", &tovb2);
    printf("2. Vvedite tekushyi tovarooborot \n");
    scanf("%f", &tovt2);
    printf("2. Vvedite indeks obyema produkcii \n");
    scanf("%f", &iq2);
    printf("2. Vvedite indvidualnyi indeks \n");
    scanf("%f", &ip2);


    printf("3. Vvedite nazvanie produkta \n");
    scanf("%s", name3);
    printf("3. Vvedite bazisnyi tovarooborot \n");
    scanf("%f", &tovb3);
    printf("3. Vvedite tekushyi tovarooborot \n");
    scanf("%f", &tovt3);
    printf("3. Vvedite indvidualnyi indeks \n");
    scanf("%f", &iq3);
    printf("3. Vvedite indvidualnyi indeks \n");
    scanf("%f", &ip3);

    printf("------------------------------------------------------| \n");
    printf("|Tovar |bazisnyi|tekushyi| | | Q1/IP | \n");
    printf("| | tovarooborot | | | | \n");
    printf("| | | iq | ip | | \n");
    printf("|--------|--------|--------|-----------------|--------| \n");
    printf("|%8s |%4.1f |%4.1f | %2.2f | %2.3f | %2.3f | \n",name1,tovb1,tovt1,iq1,ip1, del1=tovt1/ip1);
    printf("|%8s |%4.1f |%4.1f | %2.2f | %2.3f | %2.3f | \n",name2,tovb2,tovt2,iq2,ip2, del2=tovt2/ip2);
    printf("|%8s |%4.1f |%4.1f | %2.2f | %2.3f | %2.3f | \n",name3,tovb3,tovt3,iq3,ip3, del3=tovt3/ip3);
    printf("------------------------------------------------------| \n");
    printf("| summa | | | | | | \n");
    printf("| |%4.1f |%4.1f | | |%4.1f | \n", del1=tovb1+tovb2+tovb3, sum2=tovt1+tovt2+tovt3, dellall=del1+del2+del3);
    printf("|-----------------------------------------------------| \n");
    getchar();

    system("cls");
    cout<<"Summy tovarooborotov:" << sum1 << sum2;
    cout << " Nahodim obshsiy indeks tovarooborota: \n";
    indtov = sum2/sum1;
    cout << setiosflags(ios::scientific);
    cout << setw(1)<< setprecision(4);
    cout << "Rezultat:" << indtov ;
    getchar();


    system("cls");
    cout <<" Nahodim obshsiy index cen: \n";
    indcen = sum2/dellall;
    cout << setiosflags(ios::scientific);
    cout << setw(1)<< setprecision(4);
    cout << "Rezultat:" << indcen ;
    getchar();

    float indfiz;

    system("cls");
    cout << "Nahodim obshsiy indeks fizicheskogo obyema produkcii \n";
    indfiz=indtov/indcen;
    cout << setiosflags(ios::scientific);
    cout << setw(1)<< setprecision(4);
    cout << "Rezultat:" << indfiz ;
    getchar();

    return 0;
    }



    int disp()

    {

    int ix1, ix2, ix3, ix4;

    unsigned short f1,f2,f3,f4;
    unsigned short fi1,fi2,fi3,fi4;
    unsigned short m1, m2, m3, m4;
    unsigned short midf1, midf2, midf3, midf4;
    unsigned short midi1, midi2, midi3, midi4;
    unsigned short midm1, midm2, midm3, midm4;


    printf(" 1. Vvedite kolichestvo izgotovlenyh detaley\n");
    scanf("%i", ix1);
    printf("1.kol-vo rabochih imeyushih dannuyu proizvoditelnost' v 1 brigade\n");
    scanf("%d", f1);
    printf("1.kol-vo rabochih imeyushih dannuyu proizvoditelnost' v 2 brigade\n");
    scanf("%d", fi1);

    printf(" 2. Vvedite kolichestvo izgotovlenyh detaley \n");
    scanf("%i", ix2);
    printf("2.kol-vo rabochih imeyushih dannuyu proizvoditelnost' v 1 brigade\n");
    scanf("%d", f2);
    printf("2.kol-vo rabochih imeyushih dannuyu proizvoditelnost' v 2 brigade\n");
    scanf("%d", fi2);

    printf(" 3. Vvedite kolichestvo izgotovlenyh detaley\n");
    scanf("%i", ix3);
    printf("3. Kol-vo rabochih imeyushih dannuyu proizvoditelnost' v 1 brigade \n");
    scanf("%d", f3);
    printf("3. Kol-vo rabochih imeyushih dannuyu proizvoditelnost' v 2 brigade \n");
    scanf("%d", fi3);

    float suman, summ, sumf, sumif, sumit, summy;



    system ("cls");
    printf("------------------------------------------------------------------------|\n");
    printf("| ix1 | brigada 1 | brigada 2| mi | opredelenie srednih velichin |\n");
    printf("| | f1 | fi1 | | ix1*f1 | ix1*fi1 | ix1*mi |\n");
    printf("-----------------------------------------------------------------------------------------------------|\n");
    printf("| %2i | %2d | %2d | %3d | %3d | %3d | %3d |\n", ix1, f1, fi1, m1, midf1=ix1*f1, midi1=ix1*fi1, midm1=ix1*m1);
    printf("-----------------------------------------------------------------------------------------------------|\n");
    printf("| %2i | %2d | %2d | %3d | %3d | %3d | %3d |\n", ix2, f2, fi2, m2, midf2=ix2*f2, midi2=ix2*fi2, midm2=ix2*m2);
    printf("-----------------------------------------------------------------------------------------------------|\n");
    printf("| %2i | %2d | %2d | %3d | %3d | %3d | %3d |\n", ix3, f3, fi3, m3, midf3=ix3*f3, midi3=ix3*fi3, midm3=ix3*m3);
    printf("-----------------------------------------------------------------------------------------------------|\n");
    printf("| %2i | %2d | %2d | %3d | %3i | %3i | %3i |\n", ix4, f4, fi4, m4, midf4=ix4*f4, midi4=ix4*fi4, midm4=ix4*m4);
    printf("-----------------------------------------------------------------------------------------------------|\n");
    printf("|summa | %2d | %2d | %2d | %3f | %3f | %3f |\n", sumf=(float)ix1+(float)ix2+(float)ix3+(float)ix4, sumif=(float)f1+(float)f2+(float)f3+(float)f4, summ=(float)m1+(float)m2+(float)m3+(float)m4, suman=(float)midf1+(float)midf2+(float)midf3+(float)midf4, sumit=(float)midi1+(float)midi2+(float)midi3+(float)midi4, summy=(float)midm1+(float)midm2+(float)midm3+(float)midm4);
    printf("-----------------------------------------------------------------------------------------------------|\n");


    float proz1, proz2, sumsequence;


    cout << " Nahodim srednyuyu proizvoditelnost' truda dlya 1 brigady \n";
    proz1=suman/sumf;
    cout << setiosflags(ios::scientific);
    cout << setw(3)<< setprecision(1);
    cout << "Rezultat:" << proz1 ;
    getchar();

    cout << " Nahodim srednyuyu proizvoditelnost' truda dlya 2 brigady \n";
    proz2=sumif/sumit;
    cout << setiosflags(ios::scientific);
    cout << setw(3)<< setprecision(1);
    cout << "Rezultat:" << proz2;
    getchar();

    cout << "Nahodim srednyuyu proizvoditelnost' truda obeih brigad \n";
    sumsequence=summy/summ;
    cout << setiosflags(ios::scientific);
    cout << setw(1)<< setprecision(4);
    cout << "Rezultat:" << sumsequence;
    getchar();



    cout << "Promezhutochnye dispersii dlya 1 brigady \n" << ix1-proz1 <<"\n"
    <<ix2-proz1<<"\n"
    <<ix3-proz1<<"\n"
    <<ix4-proz1<<"\n" ;
    getchar();

    cout <<"Promezhutochnye dispersii dlya 2 brigady \n" <<ix1-proz2<<"\n"
    <<ix2-proz2<<"\n"
    <<ix3-proz2<<"\n"
    <<ix4-proz2<<"\n";
    getchar();

    cout <<" Promezhutochnaya dispersiya mi \n" <<ix1-sumsequence<<"\n"
    <<ix2-sumsequence<<"\n"
    <<ix3-sumsequence<<"\n"
    <<ix4-sumsequence<<"\n";
    getchar();

    cout << " Dispersiya 1 brigady \n";
    cout << "Rezultat: \n"
    <<pow (2,((ix1-proz1)*f1)+((ix2-proz2)*f2)+((ix3-proz1)*f3)+((ix4-proz1)*f4)/sumif);

    return 0;
    }
    Здесь реализованая продукция за месяц, то есть переменные x1, x2, x3, x4, y должны быть заданы столбцами в гистограмме, но не очень понимаю как это сделать на практике(