Технический форум

Технический форум (http://www.tehnari.ru/)
-   Помощь студентам (http://www.tehnari.ru/f41/)
-   -   Что у меня неправильно? (http://www.tehnari.ru/f41/t82885/)

bulding 24.12.2012 00:27

Что у меня неправильно?
 
Первое действие:поменять знак элементов столбца.Второе действие:вывести на экран сумму отрицательных элементов в столбце.Промежуточная функция:выполнить действия для столбцов,у которых первый элемент имеет нечетное значение.

Я знаю,что у меня есть ошибки.Помогите написать правильно

Код:

#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;

void znak(int**,int,int);
void otric(int**,int,int);
void nechetnoe(int**,int,int);

int main()
{
        int i=0,j,M,N;
        cout<<"Vvedite kolichestvo strok N= ";
        cin>>N;
        cout<<"Vvedite kolichestvo stolbcov M= ";
        cin>>M;
        int**a=new int*[N];
        a[i]=new int [M];

        for(i=0;i<N;i++)
                for(j=0;j<M;j++)
                {
                        cout<<"Vvedite a[i][j]= ";
                        cin>>a[i][j];
                }
                for(j=0;j<M;j++)
                        nechetnoe(a,M,N);
                for(i=0;i<N;i++)
                {
                        for(j=0;j<M;j++)
                        {
                                cout<<a[i][j];
                        }
                }
                        system("pause");
                        return 0;
}
void nechetnoe(int**arr,int stolb,int stroka)
{ int M,N,number;
        for(int j=0;j<stolb;j++)
        {        for(int i=0;i<stroka;i++)
          {
                    number=arr[i][j];
                        if(!(number%2==0))
                        znak(arr,M,N);
            otric(arr,M,N);
          }
        }
}
        void znak(int**arr,int stolb,int stroka)
        {
                int fl=1;
                for(int x=0;x<stolb;x++)
                {
                        for(int y=0;y<stroka;y++)
                        {
                                fl=arr[y][x]*(-1);
                        }
                        cout<<fl;
                }
        }
        void otric(int**arr,int stolb,int stroka)
        {
                int fl=0;
                for(int x=0;x<stolb;x++)
                {
                        for(int y=0;y<stroka;y++)
                        {
                                if(arr[y][x]<0)
                                        fl=fl+arr[y][x];
                                    cout<<fl<<" ";
                                        fl=0;
                        }
                }
        }



Часовой пояс GMT +4, время: 18:07.

Powered by vBulletin® Version 4.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.