int n=Convert.ToInt32(Console.ReadLine());
int [,] a=new int[n,n];
Random random = new Random();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
a[i, j] = random.Next(-10,10);
}
Console.WriteLine("Ваша матрица");
Console.Write("{0}{1}", a[i, j], "\t");
Console.WriteLine();
int min = a[0, 0];
if (min > a[i, j]) { min = a[i, j]; }
if (min == a[i, j]) { a[i, j] = 0; }
Console.WriteLine("Минимальный элемент");
Console.WriteLine(min);
Console.WriteLine("Исходная");
Console.Write("{0}{1}", a[i,j], "\t");
Console.ReadLine();
public class MyClass {
public static void main(String args[]) {
int dimention1 = 10;
int dimention2 = 5;//40
double[][] matrix = new double[dimention1][dimention2];
fill(matrix);
print(matrix);
matrix = sort(matrix, getOrder(matrix));
private static double[][] sort(double[][]matrix, int[] order)
double[][] ret = new double[matrix.length][matrix[0].length];
for (int i=0;i<matrix.length;i++ )
for (int j=0;j<matrix[i].length;j++ )
ret[i][j] = matrix[order[i]][j];
return ret;
private static void fill(double[][] matrix)
matrix[i][j] = Math.random()*10;
private static int[] getOrder(double[][] matrix)
double[] sums = new double[matrix.length];
sums[i]+=matrix[i][j];
int[] order = new int[sums.length];
for (int i=0;i<sums.length;i++ )
order[i] = i;
for (int j=i+1;j<sums.length;j++ )
if(sums[i]<sums[j])
double tmp1 = sums[i];
int tmp2 = order[i];
sums[i] = sums[j];
order[i] = order[j];
sums[j] = tmp1;
order[j] = tmp2;
return order;
private static void print(double[][] matrix )
double sum = 0.0;
System.out.print(matrix[i][j]+" ");
sum+=matrix[i][j];
System.out.println(" sum: "+sum);
System.out.println();
int n=Convert.ToInt32(Console.ReadLine());
int [,] a=new int[n,n];
Random random = new Random();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
a[i, j] = random.Next(-10,10);
}
}
Console.WriteLine("Ваша матрица");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
Console.Write("{0}{1}", a[i, j], "\t");
Console.WriteLine();
}
int min = a[0, 0];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (min > a[i, j]) { min = a[i, j]; }
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (min == a[i, j]) { a[i, j] = 0; }
Console.WriteLine("Минимальный элемент");
Console.WriteLine(min);
Console.WriteLine("Исходная");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
Console.Write("{0}{1}", a[i,j], "\t");
Console.WriteLine();
}
Console.ReadLine();
public class MyClass {
public static void main(String args[]) {
int dimention1 = 10;
int dimention2 = 5;//40
double[][] matrix = new double[dimention1][dimention2];
fill(matrix);
print(matrix);
matrix = sort(matrix, getOrder(matrix));
print(matrix);
}
private static double[][] sort(double[][]matrix, int[] order)
{
double[][] ret = new double[matrix.length][matrix[0].length];
for (int i=0;i<matrix.length;i++ )
{
for (int j=0;j<matrix[i].length;j++ )
{
ret[i][j] = matrix[order[i]][j];
}
}
return ret;
}
private static void fill(double[][] matrix)
{
for (int i=0;i<matrix.length;i++ )
{
for (int j=0;j<matrix[i].length;j++ )
{
matrix[i][j] = Math.random()*10;
}
}
}
private static int[] getOrder(double[][] matrix)
{
double[] sums = new double[matrix.length];
for (int i=0;i<matrix.length;i++ )
{
for (int j=0;j<matrix[i].length;j++ )
{
sums[i]+=matrix[i][j];
}
}
int[] order = new int[sums.length];
for (int i=0;i<sums.length;i++ )
{
order[i] = i;
}
for (int i=0;i<sums.length;i++ )
{
for (int j=i+1;j<sums.length;j++ )
{
if(sums[i]<sums[j])
{
double tmp1 = sums[i];
int tmp2 = order[i];
sums[i] = sums[j];
order[i] = order[j];
sums[j] = tmp1;
order[j] = tmp2;
}
}
}
return order;
}
private static void print(double[][] matrix )
{
for (int i=0;i<matrix.length;i++ )
{
double sum = 0.0;
for (int j=0;j<matrix[i].length;j++ )
{
System.out.print(matrix[i][j]+" ");
sum+=matrix[i][j];
}
System.out.println(" sum: "+sum);
}
System.out.println();
}
}