#include <stdio.h> 
/* Define the trade apparatus */
struct trade {double price; int number;};
double trade_price (struct trade *x) {return x -> price * x -> number;}
/* Define trade array */
struct trade *trade_pointers[100];
main ( ) {
  /* Declare various variables */
  int limit, counter, industry, number;
  double price, sum = 0.0;
  /* Read trade information */
  for (limit = 0; 3 == scanf ("%i%lf%i", &industry, &price, &number);)
    if (industry == 1 || industry == 5) {
      trade_pointers[limit] =
        (struct trade*) malloc (sizeof (struct trade));
      trade_pointers[limit] -> price = price;
      trade_pointers[limit] -> number = number;
      ++limit;
  }
  else if (industry == 0 || industry == 2
                           || industry == 3
                             || industry == 4)
    ;
  else printf ("Industry code %i is unknown!\n", industry);
  /* Compute cost */
  for (counter = 0; counter < limit; ++counter)
    sum = sum + trade_price (trade_pointers[counter]);
  printf ("The total cost of the %i selected trades is %f.\n",
                                 limit,                sum);
}
