Ну вроде бы так:Код | #include <stdio.h> #include <stdlib.h>
int Max(int *buf, int count); int IsEmpty(int *buf, int count);
int main(int argc, char *argv[]) { int i, j, count = 0, max; int a[4]; int A[4][4] = { 1,2,3,4, 2,3,-1,3, 1,3,4,1, 1,3,1,5 }; for(i = 0;i < 4 ;i++) { for(j = 0; j < 4;j++) { if(A[i][j] < 0) { count++; } } a[i] = count; count = 0; } if(IsEmpty(a, 4)) { printf("This matrix do not contains negative numbers\n"); } else { max = Max(a,4); for(i = 0; i< 4;i++) { a[i] = A[max][i]; printf("%d",a[i]); printf(" "); } } system("PAUSE"); return 0; }
int Max(int *buf, int count) { int i; int m = 0; for(i = 1; i < count; i++) { if (buf[i] > buf[m]) { m = i; } } return m; } int IsEmpty(int *buf, int count) { int i,s = 0; for(i = 0; i < count; i++) { s += buf[i]; } if(s) return 0; else return 1; }
|
Правда как по мне немного громоздко получилось, но ничего...
|