-
Here's a version to dynamically create a 2D array and then look for it:
#include
#include
int main()
int n,m;
std::cout<<"Please enter Row (n) Column (m) for the matrix";
std::cin>>n>>m;
int * arr=new int[n*m];
for(int i=0;i!=n;++i)for(int j=0;j!=m;++j)std::cout<<"["<>arr[i*m+j];
std::vector* arr_vec=new std::vector[m];
for(int i=0;i!=n;++i)int p=i*m+0;
for(int j=0;j!=m;++j)if(arr[i*m+j]>arr[p])p=i*m+j;
p-=i*m;
arr_vec[p].push_back(i);
for(int i=0;i!=m;++i)int p=i;
for(int j=i;j<=(n-1)*m+i;j+=m)if(arr[j]p=j;p-=i;
p%=m;for(int j=0;j != (arr_vec[i]).size();j)
if(arr_vec[i][j]==p)
std::cout<<"found! its ["<:system("pause");
-
#include
void main()
int a[2][3];
int i=0,j=0,k=0;
int max=0,min=0;
int x=0,y=0;
for(i=0;i<2;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
Find the largest in each row.
for(i=0;i<2;i++)
max=a[i][0];
for(j=1;j<3;j++)
if(a[i][j]>max)
max=a[i][j];
x=j;} Find it and see if this column is the smallest.
min=a[0][x];
for(k=0;k<2;k++)
if(a[k][x]min=a[k][x];
y=k;if(max==min)
printf("There is a saddle point in line d",i);
printf("Saddle point row number: %d, column number: %d",y,x);}else printf("There is no saddle point on line d",i);
One-dimensional arrays hold the same values, but in the case of matrices, determinants. >>>More
In fact, if you have read "C Expert Programming", it is very simple, and this problem has been carefully described above. It's stored in memory as shown in the figure. n[0][5] is actually *(*n+0)+5), which is the sixth cell. >>>More
In C, here's the main part.
int x,y,x_max,y_max,max; >>>More
The conventional solution is the current analysis method, assuming that the current of size i is connected and sent out at two points of the Japanese diagonal respectively, then the electric potential at infinity can be set to the electric potential of 0, and the electric potential of the access and outlet points is assumed to be +u and -u by symmetry, and the current can be considered to flow from the access point to infinity, and then flow back to the contact point from infinity. In the previous process, the current flows symmetrically, so that the first section of the z-shaped path from the inflow point to the reserve point has the current of i 4, the second section has i 12 (i.e. i 4 is divided into 3 parts), and the third section is still above i 12 (a careful analysis of the diagram shows that this node is two flows in and two out); A similar analysis is performed in the latter process (except that the current is in opposite directions). In this way, the superimposed currents on the three paths are i 3 (i.e. i 4 + i 12), i 6, i 3, and the potential drops to ir 3 + ir 6 + ir 3 = 5ir 6, and this should be equal to the total voltage drop of 2u (i.e. 2u = 5ir 6), so the equivalent resistance r'=2u/i=5r/6 >>>More