| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 
 | #include <stdio.h>
#include <tgmath.h>
#include <string.h>
 
double sin(double), cos(double), exp(double), log(double);
 
struct {
 
  char *nom;
  double (*fon)(double);
 
} table[] = {
  "sin", sin,
  "cos", cos,
  "exp", exp,
  "log", log };
 
#define NBF (sizeof table / sizeof table[0])
 
int main(int argc, char **argv)
{
  char nom[100];
  double nb = 0;
  int i = 0;
 
  while(1)
    {
      scanf("%s", nom);
      if(strcmp(nom, "fin") == 0) return 1;
      scanf("%lf", &nb);
 
      for(i = 0; i < NBF && strcmp(table[i].nom, nom) != 0; i++);
 
      if(i < NBF) printf("%f\n", (*table[i].fon)(nb));
      else printf("%s ? \n", nom);
    }
 
  return 0;
} |