ILOVA /*
* Created by SharpDevelop.
* User: Odiljon
* Date: 09.05.2022
* Time: 10:48
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespaceLoyiha
{
class Program
{
publicstatic void Main(string[] args)
{
int m, i, j; Console.Write("Kvadrat matritsa satrlari sonini kiriting: m=");
m = int.Parse(Console.ReadLine());
double[,] a = new double[m, m];
double[] s = new double[m];
double[] k = new double[m];
double[] w = new double[m];
double[] e = new double[m];
double[] f = new double[m];
double[] d = new double[m];
double[] h = new double[m];
double P1=0,P2=0,P3=0,P4=0,P5=0;
for (i = 0; i < m; i++)
{
if(i==0){w[i]=1;} else{w[i]=0;}
}
for (i = 0; i < m; i++)
{
for (j = 0; j < m; j++)
{
Console.Write("a[" + i + "," + j + "]=");
a[i, j] = double.Parse(Console.ReadLine());
}
}
for (j = 0; j < m; j++)
{
s[j]=a[j,0];
e[j]=a[j,0];
}
for (j = 0; j < m; j++)
{
if (m != 2)
{
break;
}
Console.WriteLine(" Y (2)[ " + j + " ]=" + s[j]);
}
for(int l = 2;l{
for (i = 0; i < m; i++)
{
for (j = 0; j < m; j++)
{
k[i]+=s[j]*a[i, j];
}
}
for (j = 0; j < m; j++)
{
}
if(m>=(l+1))
{
for (j = 0; j < m; j++)
{
s[j]=0;
s[j]=k[j];
k[j]=0;
if(l==2){h[j]=s[j];}
if(l==3){f[j]=s[j];}
if(l==4){d[j]=s[j];}
}
}
}
for (j = 0; j < m; j++)
{
if (m == 2)
{
break;
}
Console.WriteLine("Y ("+m+") [ "+ j + " ]="+k[j]);
}
for(i=0;i{
switch(m)
{
case 2: Console.WriteLine(e[i]+"\t"+w[i]+"\tP("+(i+1)+")\t"+k[i]); break;
case 3: Console.WriteLine(h[i]+"\t"+e[i]+"\t"+w[i]+"\tP("+(i+1)+")\t"+k[i]); break;
case 4: Console.WriteLine(f[i]+"\t"+h[i]+"\t"+e[i]+"\t"+w[i]+"\tP("+(i+1)+")\t"+k[i]); break;
case 5: Console.WriteLine(d[i]+"\t"+f[i]+"\t"+h[i]+"\t"+e[i]+"\t"+w[i]+"\tP("+(i+1)+")\t"+k[i]); break;
default: Console.Write("Xato kiritdingiz.");break;
}
}
if(m==5)
{
double A1=((f[0]*d[2]-f[2]*d[0])*(e[0]*d[1]-e[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(e[0]*d[2]-e[2]*d[0]))*((f[0]*d[3]-f[3]*d[0])*(h[0]*d[1]-h[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(h[0]*d[3]-h[3]*d[0]))-((f[0]*d[2]-f[2]*d[0])*(h[0]*d[1]-h[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(h[0]*d[2]-h[2]*d[0]))*((f[0]*d[3]-f[3]*d[0])*(e[0]*d[1]-e[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(e[0]*d[3]-e[3]*d[0]));
double A2=((f[0]*d[2]-f[2]*d[0])*(w[0]*d[1]-w[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(w[0]*d[2]-w[2]*d[0]))*((f[0]*d[3]-f[3]*d[0])*(h[0]*d[1]-h[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(h[0]*d[3]-h[3]*d[0]))-((f[0]*d[2]-f[2]*d[0])*(h[0]*d[1]-h[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(h[0]*d[2]-h[2]*d[0]))*((f[0]*d[3]-f[3]*d[0])*(w[0]*d[1]-w[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(w[0]*d[3]-w[3]*d[0]));
double A3=((f[0]*d[2]-f[2]*d[0])*(k[0]*d[1]-k[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(k[0]*d[2]-k[2]*d[0]))*((f[0]*d[3]-f[3]*d[0])*(h[0]*d[1]-h[1]*d[0])-(f[0]*d[1]-f[1]*d[0])*(h[0]*d[3]-h[3]*d[0]))-((f[0]*d[2]-f[2]*d[0])*(h[0]*d[1]-h[1]*d[0])-(f[0]*d[1]-f[1]*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