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

 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值