/* 时间:2014.1.29 目的:题目1191:矩阵最大值 http://ac.jobdu.com/problem.php?pid=1191 */ #include <stdio.h> #include <malloc.h> int main() { int m, n, i, j, cnt; int p[105][105]; int max, flag; while(~scanf("%d%d", &m, &n)) { for(i = 0; i < m; i++) { max = -2000000000; cnt = 0; for(j = 0; j < n; j++) { scanf("%d",&p[i][j]); cnt+=p[i][j]; if(p[i][j] > max) { max = p[i][j]; flag = j; } } p[i][flag] = cnt; } for(i = 0; i < m; i++,printf("\n")) for(j = 0; j < n; j++) j!=n-1?printf("%d ", p[i][j]):printf("%d", p[i][j]); } return 0; } /* --------------- 3 3 思路:1. 其实就是模拟 3 2 3 2 3 2 3 2 3 8 2 3 2 7 2 8 2 3 --------------- */
原文:http://blog.csdn.net/z_x_b5/article/details/18861423