=== C# 7.3 ===
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSLear
{
class Program
static void Main(string[] args)
IEnumerable<int> TripleDigit = SeqGen(101, 100, x => x + 1);
Console.WriteLine($"Sum: {SeqSum(TripleDigit, x => x % 7 == 0)}");
Console.ReadKey();
}
public static int SeqSum(IEnumerable<int> Seq, Func<int, bool> Filter)
int Sum = 0;
foreach(var item in Seq)
if (Filter(item)) Sum += item;
return Sum;
public static IEnumerable<T> SeqGen<T>(int n, T first, Func<T, T> next)
yield return first;
T cur = first;
for (int seqlen = 0; seqlen < n - 1; seqlen++)
cur = next(cur);
yield return cur;
#include <iostream>
#include <iomanip>
using namespace std;
int** matrCreate(int n)
int** M;
M = new int *[n];
for (int i = 0; i < n; i++)
M[i] = new int [n];
return M;
void matrInit(int** M, int n)
srand(time(0));
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
M[i][j] = rand()%199 - 99 ;
void matrPrint(int** M, int n)
cout << setw(5) << M[i][j];
cout << endl;
void matrTransform(int** M, int n)
int im, jm, max = -1000, s = 0;
if (M[i][j] > max)
max = M[i][j];
im = i;
jm = j;
if (i == j)
s += M[i][j];
M[im][jm] = s;
void clearMem(int** M, int n)
delete [] M[i];
delete [] M;
int main()
int n;
cin >> n;
int **A;
A = matrCreate(n);
matrInit(A, n);
matrPrint(A, n);
matrTransform(A, n);
clearMem;
return 0;
=== C# 7.3 ===
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSLear
{
class Program
{
static void Main(string[] args)
{
IEnumerable<int> TripleDigit = SeqGen(101, 100, x => x + 1);
Console.WriteLine($"Sum: {SeqSum(TripleDigit, x => x % 7 == 0)}");
Console.ReadKey();
}
public static int SeqSum(IEnumerable<int> Seq, Func<int, bool> Filter)
{
int Sum = 0;
foreach(var item in Seq)
{
if (Filter(item)) Sum += item;
}
return Sum;
}
public static IEnumerable<T> SeqGen<T>(int n, T first, Func<T, T> next)
{
yield return first;
T cur = first;
for (int seqlen = 0; seqlen < n - 1; seqlen++)
{
cur = next(cur);
yield return cur;
}
}
}
}
#include <iostream>
#include <iomanip>
using namespace std;
int** matrCreate(int n)
{
int** M;
M = new int *[n];
for (int i = 0; i < n; i++)
M[i] = new int [n];
return M;
}
void matrInit(int** M, int n)
{
srand(time(0));
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
M[i][j] = rand()%199 - 99 ;
}
void matrPrint(int** M, int n)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
cout << setw(5) << M[i][j];
cout << endl;
}
}
void matrTransform(int** M, int n)
{
int im, jm, max = -1000, s = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if (M[i][j] > max)
{
max = M[i][j];
im = i;
jm = j;
}
if (i == j)
s += M[i][j];
}
}
M[im][jm] = s;
}
void clearMem(int** M, int n)
{
for (int i = 0; i < n; i++)
{
delete [] M[i];
}
delete [] M;
}
int main()
{
int n;
cin >> n;
int **A;
A = matrCreate(n);
matrInit(A, n);
matrPrint(A, n);
cout << endl;
matrTransform(A, n);
matrPrint(A, n);
clearMem;
return 0;
}