What would be logic? interesting (Visual Studio C# .Net)

Hi,
I want to manipulate the data as a small part of my project.In short I have an array[250,200] ,where numbers(actullay binary no.s) are stored .For simply let`s

[code]int[,] array;
array = new int[5, 5];[/code]
data are stored in array[,] as :
12345
12345
12345
12345
12345 OR
123451234512345123451234512345

I want manipulate the data as:
12345
54321
12345
54321
12345 OR
1234554321123455432112345
Means that :
[code]Array[0,0]= Array[0,0];
Array[0,1]= Array[0,1];
Array[0,2]= Array[0,2];
Array[0,3]= Array[0,3];
Array[0,4]= Array[0,4];

Array[1,0]= Array[1,4];
Array[1,1]= Array[1,3];
Array[1,2]= Array[1,2];
Array[1,3]= Array[1,1];
Array[1,4]= Array[1,0];


Array[2,0]= Array[2,0];
Array[2,1]= Array[2,1];
Array[2,2]= Array[2,2];
Array[2,3]= Array[2,3];
Array[2,4]= Array[2,4];

Array[3,0]= Array[3,4];
Array[3,1]= Array[3,3];
Array[3,2]= Array[3,2];
Array[3,3]= Array[3,1];
Array[3,4]= Array[3,0];

Array[4,0]= Array[4,0];
Array[4,1]= Array[4,1];
Array[4,2]= Array[4,2];
Array[4,3]= Array[4,3];
Array[4,4]= Array[4,4];[/code]

Please send the strong and efficient logics because I have array[250,200]

Comments

  • : Hi,
    : I want to manipulate the data as a small part of my project.In short
    : I have an array[250,200] ,where numbers(actullay binary no.s) are
    : stored .For simply let`s
    :
    : [code]: int[,] array;
    : array = new int[5, 5];[/code]:
    : data are stored in array[,] as :
    : 12345
    : 12345
    : 12345
    : 12345
    : 12345 OR
    : 123451234512345123451234512345
    :
    : I want manipulate the data as:
    : 12345
    : 54321
    : 12345
    : 54321
    : 12345 OR
    : 1234554321123455432112345
    : Means that :
    : [code]: Array[0,0]= Array[0,0];
    : Array[0,1]= Array[0,1];
    : Array[0,2]= Array[0,2];
    : Array[0,3]= Array[0,3];
    : Array[0,4]= Array[0,4];
    :
    : Array[1,0]= Array[1,4];
    : Array[1,1]= Array[1,3];
    : Array[1,2]= Array[1,2];
    : Array[1,3]= Array[1,1];
    : Array[1,4]= Array[1,0];
    :
    :
    : Array[2,0]= Array[2,0];
    : Array[2,1]= Array[2,1];
    : Array[2,2]= Array[2,2];
    : Array[2,3]= Array[2,3];
    : Array[2,4]= Array[2,4];
    :
    : Array[3,0]= Array[3,4];
    : Array[3,1]= Array[3,3];
    : Array[3,2]= Array[3,2];
    : Array[3,3]= Array[3,1];
    : Array[3,4]= Array[3,0];
    :
    : Array[4,0]= Array[4,0];
    : Array[4,1]= Array[4,1];
    : Array[4,2]= Array[4,2];
    : Array[4,3]= Array[4,3];
    : Array[4,4]= Array[4,4];[/code]:
    :
    : Please send the strong and efficient logics because I have
    : array[250,200]
    :

    This should actually be very easy.

    Think of it like this:
    You want to change every other row, so then:
    for(int i=0; i<250; i+=2)
    And then do what you want with every row.

    Your code is faulty, it would result in 54345.
    You would need to use a temporary array for it to give the result you want (ok, you don't need to, but it's the best way).
  • : This should actually be very easy.
    :
    : Think of it like this:
    : You want to change every other row, so then:
    : for(int i=0; i<250; i+=2)
    : And then do what you want with every row.
    :
    : Your code is faulty, it would result in 54345.
    : You would need to use a temporary array for it to give the result
    : you want (ok, you don't need to, but it's the best way).

    Array.Reverse(array[]); is a other solution.

    for(int i=0; i<250; i+=2)<-- it's means that
    i=0
    i=2
    i=4.......i=250
    but i lose i=1,i=3,i=5...........


    you right it would result in 50000.But it is necessary because the data of this array is a part of image processing.......and i try to manipulate the data for the image processing purpose.

    Solution is here:
    for ( int i = 0 ; i < 250 ; i++ )
    {
    for( int j = 0 ; j < 200 ; j++ )
    {
    if ( i%2 == 0 )
    {
    Array[i,j] = Array [ i, j ];
    }
    else
    {
    Array[i,j] = Array[ i, (i-j)+1 ];
    }
    }
    }



    Thanks
  • : : This should actually be very easy.
    : :
    : : Think of it like this:
    : : You want to change every other row, so then:
    : : for(int i=0; i<250; i+=2)
    : : And then do what you want with every row.
    : :
    : : Your code is faulty, it would result in 54345.
    : : You would need to use a temporary array for it to give the result
    : : you want (ok, you don't need to, but it's the best way).
    :
    : Array.Reverse(array[]); is a other solution.
    :
    : for(int i=0; i<250; i+=2)<-- it's means that
    : i=0
    : i=2
    : i=4.......i=250
    : but i lose i=1,i=3,i=5...........
    :
    [blue]
    Then start at 1:
    for(int i=1; i<250; i+=2)
    [/blue]

    :
    : you right it would result in 50000.But it is necessary because the
    : data of this array is a part of image processing.......and i try to
    : manipulate the data for the image processing purpose.
    :
    : Solution is here:
    : for ( int i = 0 ; i < 250 ; i++ )
    : {
    : for( int j = 0 ; j < 200 ; j++ )
    : {
    : if ( i%2 == 0 )
    : {
    : Array[i,j] = Array [ i, j ];
    : }
    : else
    : {
    : Array[i,j] = Array[ i, (i-j)+1 ];
    : }
    : }
    : }
    :

    Are you aware of that you're doing a=a for 25000 times?
    And still, you're doing it wrong. If it's an image, the operations would result, not in a mirrored image, but half a mirrored and half a normal, which is not the problem you described.

    This is a better version:
    [code]
    var a;
    for (int i=1; i<250; i+=2){
    for(int j=0; j<100; j++){
    a = Array[i,j];
    Array[i,j] = Array[i,200-j];
    Array[i,200-j] = a;
    }
    }
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion