9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
guia01/ej1.c (688B)
   1 #include <stdio.h>
   2 
   3 #define DIVISA_NAME_ARS    "Pesos"
   4 #define DIVISA_NAME_BRL    "Reales"
   5 #define DIVISA_NAME_USD    "Dolares"
   6 #define DIVISA_NAME_EUR "Euros"
   7 
   8 #define MAX_DIVISAS    4
   9 
  10 typedef enum {
  11     ARS, BRL, USD, EUR
  12 } divisa_t;
  13 
  14 
  15 int main( void ) {
  16 
  17     divisa_t divisa_origen = ARS;
  18     divisa_t divisa_final = USD;
  19 
  20     float monto_origen, monto_final;
  21 
  22     monto_origen = 1000;
  23     
  24 
  25 
  26     float divisas[MAX_DIVISAS][MAX_DIVISAS] = {
  27         {1.000, 0.067, 0.012, 0.011},    //    ARS
  28         {0.067, 1.000, 0.190, 0.160},    //    BRL
  29         {0.012, 0.190, 1.000, 0.850},    //    USD
  30         {0.011, 0.160, 0.850, 1.000}    //    EUR
  31     };
  32 
  33     monto_final = (monto_origen * divisas[divisa_origen][divisa_final]);
  34     printf("%f\n", monto_final);
  35 
  36     return 0;
  37 }
  38 
  39