Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
64
Task/Text-processing-2/Aime/text-processing-2.aime
Normal file
64
Task/Text-processing-2/Aime/text-processing-2.aime
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
void
|
||||
check_format(list l)
|
||||
{
|
||||
integer i;
|
||||
text s;
|
||||
|
||||
if (l_length(l) != 49) {
|
||||
error("wrong number of fields");
|
||||
}
|
||||
|
||||
s = lf_q_text(l);
|
||||
if (length(s) != 10 || character(s, 4) != '-' || character(s, 7) != '-') {
|
||||
error("bad date format");
|
||||
}
|
||||
atoi(delete(delete(s, 7), 4));
|
||||
|
||||
i = 1;
|
||||
while (i < 49) {
|
||||
l_r_real(l, i, atof(l_q_text(l, i)));
|
||||
i += 1;
|
||||
l_r_integer(l, i, atoi(l_q_text(l, i)));
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
integer goods;
|
||||
file f;
|
||||
list l;
|
||||
record r;
|
||||
|
||||
goods = 0;
|
||||
|
||||
f_affix(f, "readings.txt");
|
||||
|
||||
while (f_list(f, l, 0) != -1) {
|
||||
if (!trap(check_format, l)) {
|
||||
if (r_key(r, l_head(l))) {
|
||||
v_text(cat3("duplicate ", l_head(l), " line\n"));
|
||||
} else {
|
||||
integer i;
|
||||
|
||||
r_put(r, l_head(l), 0);
|
||||
i = 2;
|
||||
while (i < 49) {
|
||||
if (l_q_integer(l, i) != 1) {
|
||||
break;
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
if (49 < i) {
|
||||
goods += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
o_integer(goods);
|
||||
o_text(" good unique lines\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue