18
26
This commit is contained in:
Arkadiusz Hypki 2025-04-14 13:35:04 +02:00
parent 208db8d25d
commit 7ab9b224bb
2 changed files with 29 additions and 0 deletions
05_AWK/in_class

10
05_AWK/in_class/04.awk Normal file
View File

@ -0,0 +1,10 @@
{
if ($1 != "#") {
if (c[$1] > 0) {
print "There is already such a country"
} else {
c[$1] = c[$1] + $2;
print "Name: ", $1, ", total population: ", c[$1];
}
}
}

19
05_AWK/in_class/05.awk Normal file
View File

@ -0,0 +1,19 @@
BEGIN {
sum = 0.0;
}
{
if ($1 != "#") {
if (c[$1] > 0) {
print "There is already such a country"
} else {
c[$1] = c[$1] + $2;
sum = sum + $3;
print "Name: ", $1, ", total population: ", c[$1];
}
}
}
END {
print "Area of all countries is ", sum
}