Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void matrica(int iMaxRed,int iMaxKol);
- int main()
- {
- FILE *fIN,*fOUT;
- int iMaxRed,iMaxKol;
- fIN=fopen("test.in","r");
- fOUT=fopen("test.out","w");
- fscanf(fIN,"%d%d",&iMaxRed,&iMaxKol);
- matrica(iMaxRed,iMaxKol);
- fclose(fIN);
- fclose(fOUT);
- return 0;
- }
- void matrica(int iMaxRed,int iMaxKol)
- {
- FILE *fIN,*fOUT;
- int aiMat[iMaxRed][iMaxKol],iBrojac1,iBrojac2,iSumRed[iMaxRed],iSumKol[iMaxKol];
- memset(iSumRed,0,sizeof(iSumRed));
- memset(iSumKol,0,sizeof(iSumKol));
- fIN=fopen("test.in","r");
- fOUT=fopen("test.out","w");
- fscanf(fIN,"%d%d",&iMaxRed,&iMaxKol);
- for (iBrojac1=0;iBrojac1<iMaxRed;iBrojac1++)
- {
- for (iBrojac2=0;iBrojac2<iMaxKol;iBrojac2++)
- {
- fscanf(fIN,"%d",&aiMat[iBrojac1][iBrojac2]);
- }
- }
- for (iBrojac1=0;iBrojac1<iMaxRed;iBrojac1++)
- {
- for (iBrojac2=0;iBrojac2<iMaxKol;iBrojac2++)
- {
- iSumRed[iBrojac1]+=aiMat[iBrojac1][iBrojac2];
- iSumKol[iBrojac2]+=aiMat[iBrojac2][iBrojac1];
- }
- }
- for (iBrojac1=0;iBrojac1<iMaxRed;iBrojac1++)
- {
- printf("%3d",iSumRed[iBrojac1]);
- fprintf(fOUT,"%3d",iSumRed[iBrojac1]);
- }
- printf("\n");
- fprintf(fOUT,"\n");
- for (iBrojac1=0;iBrojac1<iMaxKol;iBrojac1++)
- {
- printf("%3d",iSumKol[iBrojac1]);
- fprintf(fOUT,"%3d",iSumKol[iBrojac1]);
- }
- printf("\n");
- fprintf(fOUT,"\n");
- fclose(fIN);
- fclose(fOUT);
- }
Add Comment
Please, Sign In to add comment