Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Count a delivery on two planets. The manifest stays in guest RAM. */
|
||||
#include <cmoc.h>
|
||||
#include <coco.h>
|
||||
|
||||
struct Shipment
|
||||
{
|
||||
const char *destination;
|
||||
byte crates;
|
||||
byte mealsPerCrate;
|
||||
};
|
||||
|
||||
static const struct Shipment manifest[] =
|
||||
{
|
||||
{ "EARTH", 12, 20 },
|
||||
{ "MARS", 8, 15 }
|
||||
};
|
||||
|
||||
/* A pointer lets us read one row without copying the whole structure. */
|
||||
static word mealsFor(const struct Shipment *shipment)
|
||||
{
|
||||
return (word) shipment->crates * shipment->mealsPerCrate;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
word total = 0;
|
||||
byte row;
|
||||
|
||||
width(40);
|
||||
for (row = 0; row < sizeof(manifest) / sizeof(manifest[0]); ++row)
|
||||
{
|
||||
word meals = mealsFor(&manifest[row]);
|
||||
printf("%s: %u MEALS\n", manifest[row].destination, meals);
|
||||
total += meals;
|
||||
}
|
||||
printf("TOTAL: %u MEALS\n", total);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user