#includeintmain(){int m, n, i, j;int arr[100][100];scanf("%d %d",&m,&n);for(i =1; i <= m; i++){for(j =1; j <= n; j++){scanf("%d",&arr[i][j]);}}int flag =0;for(i =2; i <= m-1; i++){for(j =2; j <= n-1; j++){if(arr[i][j]> arr[i -1][j]&& arr[i][j]> arr[i +1][j]&& arr[i][j]> arr[i][j -1]&& arr[i][j]> arr[i][j +1]){printf("%d %d %d\n", arr[i][j], i, j);flag =1;}}}if(flag ==0){printf("None %d %d", m, n);}return0;}
7-2 求矩阵各行元素之和
#includeintmain(){int m, n, i, j;int arr[10][10];scanf("%d %d",&m,&n);for(i =0; i < m; i++){for(j =0; j < n; j++){scanf("%d",&arr[i][j]);}}int sum =0;for(i =0; i < m; i++){for(j =1; j < n; j++){arr[1][0]+= arr[i][j];}}for(i =0; i < m; i++)printf("%d\n", arr[i][0]);return0;}
7-3 判断上三角矩阵
#includeintmain(){int T, i, j, n,k;int a[10][10];scanf("%d",&T);for(k =0; k < T; k++){scanf("%d",&n);for(i =0; i < n; i++){for(j =0; j < n; j++){scanf("%d",&a[i][j]);}}int flag =1;for(int x =1; x < n; x++){for(int y =0; y < x; y++){if(a[x][y]!=0){flag =0;break;}}if(flag ==0)break;}if(flag ==1)printf("YES\n");elseprintf("NO\n");}return0;}
7-4 点赞
#includeintmain(){int n, m, i, j;int num =0, max =0, maxpos =1000;scanf("%d",&n);int flag[1001]={0};for(i =0; i < n; i++){scanf("%d",&m);for(j =0; j < m; j++){scanf("%d",&num);flag[num]++;}}for(i =1000; i >0; i--){if(flag[i]> max){max = flag[i];maxpos = i;}}printf("%d %d", maxpos, max);return0;}