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
int[,] array;
array = new int[5, 5];
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 :
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];
Please send the strong and efficient logics because I have array[250,200]
Loading
Posted Aug 3, 2007, 7:02 AM
namespace ArrayLogic
{
class Program
{
static void Main(string[] args)
{
int[,] Array = new int[5, 5];
//This Loop is used to inser the values in the array
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
Array[i, j] = int.Parse(Console.ReadLine());
}
}
//This Loop is used to Print the inserted values of the array
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
Console.Write(Array[i, j]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.ReadLine();
//This Loop is used to Print the Wanted output
for (int i = 0; i < 5; i++)
{
if (i % 2 == 0)
{
for (int j = 0; j < 5; j++)
{
Console.Write(Array[i, j]);
Console.Write(" ");
}
Console.WriteLine();
}
else
{
for (int j = 4; j >=0; j--)
{
Console.Write(Array[i, j]);
Console.Write(" ");
}
Console.WriteLine();
}
}
}
}
}
SamPosted Aug 3, 2007, 6:17 AM
Something like this should work
public static void Test(int[,] A){
Stack<int> S = new Stack<int>(); for (int i = 0; i < 250; i++){
if ((i & 1) == 1) // Test if odd{
for (int k = 0; k < 200; k++){
S.Push(A[i, k]);
}
for (int k = 0; k < 200; k++){
A[i, k] = S.Pop();
}
}
}
}
Hope this helps,
Sam.
Edit: The Stack class is requires .NET 2.0 or 3.0 and is in the System.Collections.Generic namespace