473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

1
I cant get with part of it is wrong, i want to sum every row, too.
Expand|Select|Wrap|Line Numbers
  1. // Color Number.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<conio.h>
  6. #include<iostream>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. using namespace std;
  10.  
  11. int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.     int k,sum;
  14.     cout << "Enter the Graph vertex number: ";
  15.     cin >> k;
  16.     int i, j, *a, b[100];
  17.     a = new int [i][j];
  18.     cout << "your Gragh is" << k << " , " << k << ", enter your numbers:"<< endl;
  19.     for (i = 0; i<k; i++)
  20.     {
  21.         for (j = 0; j<k; j++)
  22.         {
  23.             cout << "[ " << i + 1 << " , " << j + 1 << " ] = ";
  24.             cin >> a[i*j];
  25.         }
  26.         cout << endl;
  27.     }
  28.     for (i = 0; i<k; i++)
  29.     {
  30.         for (j = 0; j<k; j++)
  31.         {
  32.         sum += a[j];
  33.         }
  34.         b[i] = sum;
  35.         cout << b[i];
  36.         sum = 0;
  37.     }
  38.     return 0;
  39. }
Apr 23 '14 #1
1 1193
zmbd
5,501 Expert Mod 4TB
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.
Apr 23 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: middletree | last post by:
OK, you pros out there are rolling your eyes at the subject line, but I have never had to use arrays before. The scenario: ASP Intranet app keeps track of trouble tickets for a tech support group....
11
by: - Steve - | last post by:
For a school assignment I need to write a class to work with the following code. The IntArray b(-3, 6) basically means that I need to produce an array of integer values that has an index going...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
8
by: Greg | last post by:
In VB6 I made heavy use of control arrays I see they have been 'deprecated' in vb.Net, with a questionable explanation that they are no longer necessary which just addresses the event issue!...
9
by: Anil Gupte | last post by:
I am having a problem using Multidim arrays. I want to create an array which as I understand it is dimensioned as: dim xyz (rows,columns) as String I want to populate it with rows from a...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
1
by: Ruzty | last post by:
Good day! This is my first time here. I haven't slept for days because of my project in school. Please help me... The Problem is: using two dimensional arrays create a java program the will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.