• 3- misol . ** tipidagi funksiyalar parametrlari
  • - misol . Dinamik matritsalar




    Download 0,63 Mb.
    bet6/6
    Sana23.05.2024
    Hajmi0,63 Mb.
    #250890
    1   2   3   4   5   6
    Bog'liq
    3-Mustaqil ishi ROZIYEVA I

    2- misol . Dinamik matritsalar

    #include

    #o'z ichiga

    #include

    void main()

    { int **a, n, m, i, j; //n-satrlar soni, m-ustunlar soni;

    cout<<"Kiritish n,m\n";

    cin>>n>>m;

    a=(int**)malloc(n*sizeof(int*));

    cout<<"Kirish matritsasi\n";

    uchun (i=0;i

    {

    a[i]=(int*)malloc(m*sizeof(int));

    uchun (j=0;j

    cin>>a[i][j];//*(*(a+i)+j)

    }

    uchun (i=0;i

    uchun (j=0;j

    a[i][j]=2*a[i][j];

    cout<<"O'zgartirilgan matritsa:\n";

    uchun (i=0;i

    {for(j=0;j

    cout<

    cout<

    bepul(a[i]);

    }

    _getch();

    bepul(a);

    }


    #include
    #o'z ichiga
    void main()
    { int **a, n, m, i, j;
    cout<<"Kiritish n,m\n";
    cin>>n>>m;
    a=yangi int*[n];
    cout<<"Kirish matritsasi\n";
    uchun (i=0;i{ a[i]=yangi int[m ];
    uchun (j=0;jcin>>a[i][j];//*(*(a+i)+j)
    }
    uchun (i=0;iuchun (j=0;ja[i][j]=2*a[i][j];
    cout<<"O'zgartirilgan matritsa:\n";
    uchun (i=0;i{ for(j=0;jcout<cout<o'chirish [] (a[i]);
    }
    o'chirish [] a;
    _getch();
    }
    siz turli uzunlikdagi matritsa qatorlarini yasashingiz mumkin - m ni tsiklga kiritish

    3- misol . ** tipidagi funksiyalar parametrlari

    #include

    #o'z ichiga

    float sum(float **a, int n, int m);

    void main()

    { float **a; int n, m, i, j;

    cout<<"Kirish n,m"<

    cin>>n>>m;

    a=yangi float*[n];

    uchun (i=0;i

    { a[i]=yangi float[m];

    uchun (j=0;j

    cin>>a[i][j];

    }

    cout<<"sum="<

    _getch();

    uchun (i=0;i

    o'chirish [] a[i];

    o'chirish [] a;

    }


    float summasi(float **a, int n, int m)
    {
    float s; int i,j;
    s=0;
    uchun (i=0;iuchun(j=0;js=s+a[i][j];
    qaytish(lar);
    }
    Download 0,63 Mb.

    1   2   3   4   5   6




    Download 0,63 Mb.