using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[3,3];
int i, j,result = 0;
Console.WriteLine("Please enter 9 numbers ");
for (i=0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
a[i,j] = Int16.Parse(Console.ReadLine());
}
}
Console.WriteLine("Entered numbers");
result = a[0, 0];
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.Write(a[i, j] + " ");
if (a[i, j] >= result)
{
result = a[i, j];
}
}
Console.WriteLine();
}
Console.WriteLine(result + " is a biggest number");
Console.ReadLine();
}
}
}
Thanks for your sharing,i learn a lot.I have a 2D array (an image actually) that is size N x N. I need to find the indices of the M largest values in the array ( M << N x N) . Linearized index or the 2D coords are both fine. The array must remain intact (since it's an image). I can make a copy for scratch, but sorting the array will bugger up the indices.I'm fine with doing a full pass over the array (ie. O(N^2) is fine). Anyone have a good algorithm for doing this as efficiently as possible?
ReplyDeletecreate 2d qrcode in c#