2D danamic arrays, how to create and give values(i,j)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arashe
    New Member
    • Apr 2014
    • 1

    2D danamic arrays, how to create and give values(i,j)

    I cant get with part of it is wrong, i want to sum every row, too.
    Code:
    // Color Number.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include<conio.h>
    #include<iostream>
    #include <stdlib.h>
    #include <string.h>
    using namespace std;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	int k,sum;
    	cout << "Enter the Graph vertex number: ";
    	cin >> k;
    	int i, j, *a, b[100];
    	a = new int [i][j];
    	cout << "your Gragh is" << k << " , " << k << ", enter your numbers:"<< endl;
    	for (i = 0; i<k; i++)
    	{
    		for (j = 0; j<k; j++)
    		{
    			cout << "[ " << i + 1 << " , " << j + 1 << " ] = ";
    			cin >> a[i*j];
    		}
    		cout << endl;
    	}
    	for (i = 0; i<k; i++)
    	{
    		for (j = 0; j<k; j++)
    		{
    		sum += a[j];
    		}
    		b[i] = sum;
    		cout << b[i];
    		sum = 0;
    	}
    	return 0;
    }
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    By, simply stating that your code "doesn't work," posting code that appears to have had very little if any troubleshooting performed, and expecting someone to help doesn't usually result in much of an answer and may result in your thread being deleted.

    Instead, please tell us what you were expecting to happen, what actually happened, for each error: the EXACT title, error number, and descriptions that occurred and at what line in your posted code the error occurred.

    These are the minimum requirements for posting a question of this nature.

    Comment

    Working...