![4ba7d2be52aa039c426c027691950e95.png](https://i-blog.csdnimg.cn/blog_migrate/594a6a6d0b3bdd5966ed521c0b3f4495.png)
01.计算鞍点
![dff734055e19fa27725087dde983de8d.png](https://i-blog.csdnimg.cn/blog_migrate/cf54f6b3d4f1c68b503cc74a8d85f858.png)
for (i = 0; i <= 4; i++)
{
max[i] = a[i][0];//最大值初始化为行首项
for (j = 0; j <= 4; j++)
{
if (a[i][j] > max[i])
{
max[i] = a[i][j];
d = j;//记下列数
}
}//寻找同行最大值
min = a[0][d];//最小值初始化为列首项
for (b = 0; b <= 4; b++)
{
if (a[b][d] < min)
{
min = a[b][d];
e = b;//记下行数
}
}
if (e == i) //若位置相同则输出鞍点
{printf("%d %d %d",e+1,d+1,a[e][d]);}
else c = c + 1;
d = 0;
e = 0;
}
if (c == 5) printf("not found");
02.反转字符数组元素
![ef73d7ae269bacaaba0fd615fe24e51d.png](https://i-blog.csdnimg.cn/blog_migrate/001ce9154f8b184dc1210e0b8d1a1ce1.png)
gets(str);//键入数组
int len, i;
len = strlen(str);//会用到
char temp;
for (i = 0; i <= len-i-1; i++)
{
temp = str[i];
str[i] = str[len - 1 - i];
str[len - 1 - i] = temp;
}
printf("%s", str);
03.交换矩阵指定的行
![b08f03b5f79740944b402a9b0c82a083.png](https://i-blog.csdnimg.cn/blog_migrate/873246b62afeedc50d3d2a0044567664.png)
int m, n, temp;
scanf("%d %d",&m,&n);//键入要交换的两行数
for (j = 0; j <= 4; j++)
{
temp = a[m-1][j];
a[m-1][j] = a[n-1][j];
a[n-1][j] = temp;
}
for (i = 0; i <= 4; i++)
{
for (j = 0; j <= 4; j++)
{
if (j <= 3)
printf("%d ", a[i][j]);
else
printf("%d\n", a[i][j]);//输出时,每行最后一位后无空格
}
}
04.附加题-最大子数组
![7b1a82a5cd1290f5e6f998df6be0a388.png](https://i-blog.csdnimg.cn/blog_migrate/40ca2096a184698bbf2d42b622437b7b.png)
int max= a[0];
int len, sum;
int m, n;//m为首项,n为末项
for (i = 0; i < 10; i++)
{
for (len = 1;len<10-i;len++)
{
sum = 0;
for (j = i; j < i + len; j++)
{
sum += a[j];
}
if (max < sum)
{
max = sum;
m = i;
n = len + i - 1;
}
}
}
for (i = m; i <= n; i++)
{
printf("%d ",a[i]);
}
printf("%d", max);
![6062b1edb7ba831a75f2208842a077fb.png](https://i-blog.csdnimg.cn/blog_migrate/515e0b9c361a4eae71c05420cff3e402.jpeg)
下期见!
![475a43e2d7367f95ea977add37fd988b.gif](https://i-blog.csdnimg.cn/blog_migrate/606b23cbb8bcb85ae557f2b6c2e510b0.gif)
![902277629986aa836f512a7ee00d472c.png](https://i-blog.csdnimg.cn/blog_migrate/5b7ec56ce3ebda04a591172416795846.jpeg)
南 开 软 件
职业发展部出品
文案&排版|吴祎璠