0

No.5 Lab 5_матрицы

Posted by ေမၿမဳိ့သား on 7:17 AM in
Qus==>> В данной целочисленной матрице 5x7 заменить каждый элемент строки на среднее арифметическое значение этой строки.
#include "stdafx.h"
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<stdlib.h>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
        int i,j;
        const int row=5,col=7;
        int soe[row][col];
       
        for(i=0;i<row;i++)
        {
                for(j=0;j<col;j++)
                {
                    soe[i][j]=rand()%50+5;
                    cout<<setw(5)<<soe[i][j];
                    //sum=sum+soe[i][j];
                }
                cout<<"\n\n\n";
        }
        //cout<<"\n\n MATRIX ALL's SUM===>>"<<sum;
int moe[20];
int sum=0;
for(i=0;i<row;i++)
{
                for(j=0;j<col;j++)
                {
                        sum=sum+soe[i][j];
                        moe[i]=sum;

                }
                cout<<"EVERY ROW====>>>";
        getch();
    return 0;
}


0 Comments

Post a Comment

Copyright © 2009 ~ ♥ ရည္ညႊန္းရာ ♥ ~ All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.