cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Example
Example
Oct 31, 2011 at 10:31am UTC
tundrablume
(2)
Hello everybody,
i have an algorithm which need as an input lattice basis b_1,...,b_2 ]in Z. The programm starts with
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
// determine dimension n = Number of vectors
const int n =3;
// dimension of vectors b, determine element R^d
const int d = 3;
// declare matrix, vectors level
int sa_matrix[d][n];
My question is: How can i define a matrix
2 4
3 5
Is it n=2, d=2,4,3,5 ?
Hope someone can help me please.
regards
tundrablume
Oct 31, 2011 at 1:46pm UTC
kbw
(9488)
n and d are 3, so sa_matrix is a 3 x 3 array, which you can treat as a 3 x 3 matrix.
If you want a 2 x 2 matrix implemted as a 2D array, you'll need to declare a 2 x 2 array. For example:
int
2darray[2][2] = { { 2, 4 }, { 3, 5 } };
Oct 31, 2011 at 3:49pm UTC
tfityo
(174)
@kbw
You cannot declare/use variable with name starting with digit.
int
twodarray[2][2] = { { 2, 4 }, { 3, 5 } };
is proper syntax.
Topic archived. No new replies allowed.