something wrong with my array

trying to solve this problem to display my 3X3 input to - 128


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;

double shifted_block(double a[3][3]);

int main ()
	{
		
// input number in 3X3 array
		
	double a[3][3];
	
	double zero_zero;
	*(a+0)[0] = zero_zero;
	double zero_one;
	*(a+0)[1] = zero_one;
	double zero_two;
	*(a+0)[2] = zero_two;
	
	cout << "Enter 1st row" << endl;
	cin >> zero_zero >> zero_one >> zero_two;
	
	
	double one_zero;
	*(a+1)[0] = one_zero;
	double one_one;
	*(a+1)[1] = one_one;
	double one_two;
	*(a+1)[2] = one_two;
	
	cout << "Enter 2nd row" << endl;
	cin >> one_zero >> one_one >> one_two;
	
	
	double two_zero;
	*(a+2)[0] = two_zero;
	double two_one;
	*(a+2)[1] = two_one;
	double two_two;
	*(a+2)[2] = two_two;
	
	cout << "enter 3nd row" << endl;
	cin >> two_zero >> two_one >> two_two;
	
	
	cout << zero_zero << " " << zero_one << " " << zero_two << " " << endl;
	cout << one_zero  << " " << one_one  << " " << one_two  << " " << endl;
	cout << two_zero << " " << two_one << " " << two_two << " " << endl;

//display out
				
	cout << shifted_block (zero_zero) << endl;
	
	return 0;
		
	}

// to minus 128 of the value input
		
double shifted_block(double a[3][3])
{
	
		
	for (int countrow = 0; countrow < 3; countrow++) {
		
    for (int countcolumn = 0; countcolumn < 3; countcolumn++){
	    
    return a[countrow][countcolumn] = a[countrow][countcolumn] - 128;
         
                
    }
    
}


}

Last edited on
You are assigning uninitialized variables to the various positions in the array, and only then
initializing the variables....
any example to understand better?
1
2
	double zero_zero;  // you never give zero_zero a value -- it's unitialized
	*(a+0)[0] = zero_zero;  // what are you assigning to *(a+0)[0] ?  you never set zero_zero to anything 
Last edited on
so this is like i must input zero_zero i only can get the value but what want is i want to input any value not in code but in cmd.

it have line 55 : error cannot convert 'double' to 'double' <*>[3]' for argument '1' to 'double shifted_block<double <*>[3]>'
Last edited on
Topic archived. No new replies allowed.