summaryrefslogtreecommitdiffstats
path: root/mat/euler/17/prog.c
blob: afa005dc5fac3a4d3a8068ef21b08ef4d6b15667 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
#define DISABLE_LIB_TESTS 1
#include <angnum.c>
int main (int argc, char ** argv) {
	if (argc != 1+2) {
		fprintf(stderr, "uporaba: %s <stevilka>\nprimer-sešteje črke v ang številih od 1 do 1000: %s 1 1000\n", argv[0], argv[0]);
		return 1;
	}
	long long int a = strtoll(argv[1], NULL, 10);
	long long int b = strtoll(argv[2], NULL, 10);
	unsigned long long int i = 0; // lenasI
	long long int j = 0; // Janez je podpisan, da se po 0 ne obrne (:
	unsigned long long int e = 0; // sEštevek
	char * s = malloc(sizeof(char)*MX_NS_L);
	for (i = a; i <= b; i++) {
		// fprintf(stderr, "\rračunam ... preostane še %llu operacij.", b-i);
		j = angnum(i, s, MX_NS_L);
		if (j == 0)
			return 2;
		for (j-- /* da ne gledamo nul bajta na koncu (: */ ; j >= 0; j--) {
			if (s[j] >= 'a' && s[j] <= 'z') // that's why I like C
				e++;
		}
	}
	fprintf(stdout, "\rkonec. seštevek črk je %llu.\n", e);
	return 0;
}