fork download
  1. /* Ektupwnei tis sthles me ta idia stoixeia enos pinaka 2 diastasewn */
  2.  
  3. #include<stdio.h>
  4. #define ROWS 4
  5. #define COLS 5
  6. int main(void){
  7. int i,j,k;
  8. int arr2d[ROWS][COLS]={ {2,6,1,4,0} , {8,0,5,3,3} , {4,2,20,5,16} , {1,3,4,12,16} };
  9. int found_same[COLS]={0};
  10.  
  11. for(i=0; i<COLS; ++i) {
  12. found_same[i] = 0;
  13. for (j=0; j<ROWS-1; j++) {
  14. for(k=j+1; k<ROWS; k++) {
  15. if (arr2d[j][i] == arr2d[k][i]) found_same[i] = 1;
  16. }
  17. }
  18. }
  19.  
  20. for(i=0; i<ROWS; ++i) {
  21. for (j=0; j<COLS; j++) {
  22. if (found_same[j])
  23. printf("%3d",arr2d[i][j]);
  24. }
  25. printf("\n");
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 2112KB
stdin
Standard input is empty
stdout
  0
  3
 16
 16