All pastes #805192 Raw Edit

hahahahahaha

public c v1 · immutable
·published 2007-12-04 03:42 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]){  char num;  int A[80][80], B[80][80],C[80][80];   int p, q, m, n;  int l=1, c=1, i=1, j=1;  int soma[80];  FILE *matriz1, *matriz2, *produto;  matriz1=fopen("matriz1.txt","r");  matriz2=fopen("matriz2.txt","r");  produto=fopen("produto.txt","w");     while(feof(matriz1)==0)  {     fscanf (matriz1, "%c", &num);     if (num=='\n')     {       i++;       j+=2;     }     if (num==' ')     j+=2;  }  j+=2;  m = i;  j = j/m;  n = j/2;    while(feof(matriz2)==0)  {     fscanf (matriz2, "%c", &num);     if (num=='\n')     {       l++;       c+=2;     }     if (num==' ')     c+=2;  }  c+=2;  p = l;  c = c/p;  q = c/2;     if(n!=p)  {     printf("Produto inexistente\n\n");     fprintf(produto,"Produto inexistente");     system("PAUSE");     exit(1);  }    fseek(matriz1, 0, SEEK_SET);  for(i=0;i<m;i++)  {     for(j=0;j<n;j++)     {        fscanf (matriz1, "%d", &A[i][j]);     }  }  fclose(matriz1);    fseek(matriz2, 0, SEEK_SET);  for(l=0;l<p;l++)  {     for(c=0;c<q;c++)     {        fscanf (matriz2, "%d", &B[l][c]);     }  }  fclose(matriz2);  for(i=0;i<m;i++)  {     for(c=0;c<q;c++)     {        for(j=0;j<n;j++)        {           soma[j] = A[i][j] * B[j][c];        }        for(j=1;j<n;j++)           soma[j]=soma[j]+soma[j-1];         C[i][c]=soma[j-1];     }        c=0;   }    for(i=0;i<m;i++)  {     for(j=0;j<q;j++)     {        fprintf (produto, "%d ", C[i][j]);     }     fprintf(produto, "\n");  }     system("PAUSE");  return 0;}