Name | Type | Fruit | Quantity | Price |
---|---|---|---|---|
CSE | Other | |||
Drum Lab | Buyer | Pears | 2 | 40 |
Vice Chancellors Garden | Seller | Pears | 8 | 30 |
Power Plus | Seller | Electricity | 684 | 2 |
Fruit Bin | Anything | 1000 | 1 |
Deckard makes these actions in the 4 turns the simulation lasts.
List all the changes which occur in the Fruit Bot world each turn
What is its input?
What is its output (give examples)
How does a bot indicate whether it wishes to move East/West
*** Fruit Bot Parameters *** battery_capacity=74 maximum_fruit_kg=21 maximum_move=7 *** Turn 1 of 19 *** *** CSE: other Mathews A: will buy 1 kg of Apples for $51/kg Quadrangle: other Campus Charging: will sell 100 kJ of Electricity for $4/kJ Kensington Apple Farm: will sell 3 kg of Apples for $18/kg Campus Compost Heap: will buy 1000 kg of Anything for $1/kg CLB 7: will buy 3 kg of Apples for $43/kg "Botty McBotbot" is at "CSE" with $117, battery level: 64, 5 kg of Apples "Buffalo McBuff" is at "Kensington Apple Farm" with $217, battery level: 74 "COMP1511 Student" is at "Campus Compost Heap" with $1, battery level: 24, 11 kg of Apples *** You are "Botty McBotbot"how do I read that in with scanf?
struct bot { char *name; struct location *location; int cash; int battery_level; char *fruit; int fruit_kg; int turns_left; int battery_capacity; int maximum_move; int maximum_fruit_kg; };What do the fields mean.
What value can the fields take? If int can they be negative?, zero? If pointer can they be NULL?
struct location { char *name; char *fruit; int price; int quantity; struct location *east; struct location *west; struct bot_list *bots; };What do the fields mean.
What value can the fields take? If int can they be negative?, zero? If pointer can they be NULL?
What "non-fruit" values can the field fruit take?
int mars_bars_on_board(struct bot *b)which given a pointer to a bot returns how many Mars Bars the bot has on board (yes Mars Bars are fruit)
int mars_bars_for_sale(struct bot *b)which given a pointer to a bot returns how Mars Bars are for sale at the bot's current location
Your tutor may still choose to cover some of the questions time permitting.
struct node *a, *b, *c, *d; a = NULL: b = malloc(sizeof b); c = malloc(sizeof struct node); d = malloc(8); c = a; d.data = 42; c->data = 42;
int member(int value, struct node *list);Implement this function both iteratively (using a while/for loop) and recursively.
int i; struct node *a[100]; struct node *b = malloc(sizeof (struct node)); b->data = 0; for (i = 0; i < 100; i = i + 1) { a[i] = b; } for (i = 0; i < 100; i = i + 1) { a[i]->data++; } printf("%d %d\n", a[0]->data, a[99]->data);