Skip to content

Instantly share code, notes, and snippets.

@Nadrin
Created December 5, 2011 13:32
Show Gist options
  • Save Nadrin/1433591 to your computer and use it in GitHub Desktop.
Save Nadrin/1433591 to your computer and use it in GitHub Desktop.
Suma kolumn
#include <stdio.h>
#define N 3
#define M 2
int main(int argc, char** argv)
{
int H[N][M];
int i,j, sum;
FILE *f = fopen("dane.txt", "r");
for(j=0; j<M; j++) {
for(i=0; i<N; i++) {
fscanf(f, "%d", &H[i][j]);
printf("%d ", H[i][j]);
}
printf("\n");
}
fclose(f);
for(i=0; i<N; i++) {
sum = 0;
for(j=0; j<M; j++)
sum += H[i][j];
printf("Suma %d kolumny: %d\n", i, sum);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment