-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileWithNumbers.c
57 lines (51 loc) · 1015 Bytes
/
FileWithNumbers.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <string.h>
#define MAX 100
//ne menuvaj!
void wtf()
{
FILE *f = fopen("broevi.txt", "w");
char c;
while ((c = getchar()) != EOF)
{
fputc(c, f);
}
fclose(f);
}
int main()
{
wtf();
FILE *f1;
f1 = fopen("broevi.txt", "r");
if (f1 == NULL)
{
printf("ne postoi takov file");
}
int n;
while (fscanf(f1, "%d", &n) == 1)
{
if (n == 0)
{
break;
}
int i, max = -9999, cuvajbroj = 0, broj;
for (i = 0; i < n; i++)
{
fscanf(f1, "%d", &broj);
int kopija = broj;
int svrten = 0;
while (broj != 0)
{
svrten = svrten * 10 + broj % 10;
broj = broj / 10;
}
if (svrten % 10 > max)
{
max = svrten % 10;
cuvajbroj = kopija;
}
}
printf("%d\n", cuvajbroj);
}
fclose(f1);
}