Skip to main content
gamedev.net
🔒 Locked

How to write (square[Array()() - Array2()()]) as code?

Started by BLurnewbie 6 replies 300+ views
Original Post
BLurnewbie
BLurnewbie
hi, How to write (square[Array()() - Array2()()]) as code? thanks
xg0blin
xg0blin
Let me get this straight. You''re trying to square one array item from a 2d array minus another item in the 2d array, or all of the items in two sepeterate arrays or what?
BLurnewbie
BLurnewbie
getting the sqaure of the difference
xg0blin
xg0blin
square of the difference I understand. Of the entire 2d array, or two seperate 2d arrays of the same size or what?
xg0blin
xg0blin
Ok, easy enough. We''ll say the arrays are 10x10, but they could be anything.

  
#include <math.h>

int arr1[10][10], arr2[10][10], int result;

// set the values somewhere to whatever


// I don''t know if you want to keep the values and add up a

// result or what, so I''ll just make a new result every time.


for(int i = 0; i < 10; i++)
for(int j = 0; j < 10; j++)
result = sqrt(arr1[i][j] - arr2[i][j]);


If you specify more what you need, I''d be happy to help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.