Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: C  |  size: 0.67 KB  |  hits: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main(){
  5.         int **M,*V,*C;
  6.         int n,m,A,r,Λ,FA,maior=-2000,menor=2000;
  7.         int i,j;
  8.         FILE *arq;
  9.  
  10.         arq = fopen("D:\\M.txt","r");
  11.  
  12.         if(!arq){
  13.                 printf("Erro na abertura do arquivo.\n\n");
  14.                 system("pause");
  15.                 return 0;
  16.         }
  17.  
  18.         fscanf(arq,"%d %d",&n,&m);
  19.         M = (int **)malloc(n*m*sizeof(int*));
  20.         if(!M){
  21.                 printf("Memoria insuficiente.\n\n");
  22.                 system("pause");
  23.                 return 0;
  24.    
  25.     for(i=0;i<n;i++){
  26.                 for(j=0;j<m;j++){
  27.                         fscanf(arq,"%d",&M[i][j]);
  28.                        
  29.                 }
  30.         }
  31.  
  32.         for(i=0;i<n;i++){
  33.                 for(j=0;j<m;j++){
  34.                         printf("%d  ",M[i][j]);
  35.                 }
  36.                 printf("\n\n");
  37.         }
  38.  
  39.         fclose(arq);
  40.         printf("\n\n");
  41.         system("pause");
  42.         return 0;
  43. }