سلام. من میخاستم که یک ارایه ی دو بعدی به عنوان ماتریس مجاورت بگیرم و جمع هر سطر رو توی یک خانه از یک ماتریس یک طرفه بریزم. اما نشد.
HTML:
#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 << "[" << 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;
}