您的位置:首页 > 其它

P_154找出已知矩阵中最大元素值,及所在位置

2020-06-07 06:16 11 查看
1 //找出矩阵中最大元素值,及所在位置
2 #include<iostream>
3 #include<string.h>
4 using namespace std;
5
6 int main()
7 {
8     int i,j,row=0,col=0,max;
9     int a[3][4]={{1,2,3,4},{9,8,7,6},{-10,10,-5,2}};
10     max=a[0][0];
11     for(i=0;i<=2;i++)
12     {
13         for(j=0;j<=3;j++)
14         {
15             if(a[i][j]>max)//找到比前一个大的值,将它赋值
16             {
17                 max=a[i][j];
18                 row=i;
19                 col=j;
20             }
21         }
22     }
23     cout<<max<<endl<<row<<endl<<col<<endl;
24     return 0;
25 }
26 //字符处理函数
27 /*int main()
28 {
29     char str[]="China ";
30     char str1[]="my HOME";
31     cout<<strcpy(str1,str)<<endl;
32     cout<<strlwr(str)<<endl;//大写转小写
33     cout<<strupr(str)<<endl;//小写转大写
34     cout<<strlen(str)<<endl;
35     cout<<strcat(str,str1)<<endl;//连接字符
36     return 0;
37 }*/

 

转载于:https://www.cnblogs.com/zengshangzhi/p/8779375.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐