summaryrefslogtreecommitdiffstats
path: root/mat/advent/4/prog.c
blob: 87dfa5e666827a79de144464f91346de8f16ebc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char ** argv) {
	if (argc != 1+1) {
		fprintf(stderr, "uporaba: %s <dolzina stranice kvadratne mreze>\nprimer za šahovnico: %s 8\n", argv[0], argv[0]);
		return 1;
	}
	unsigned long int n = strtol(argv[1], NULL, 10);
	unsigned long int x = 1;
	unsigned long int y = 1;
	unsigned long int s = 0;
	for (x = 1; x <= n; x++) {
		fprintf(stderr, "debug: x == %lu\n", x);
		for (y = 1; y <= n; y++)
			s = s + x * y;
	}
	fprintf(stdout, "seštevek možnih pravokotnikov v mreži %lux%lu je %lu\n", n, n, s);
}