00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include <string.h> 00004 #include "cgnslib.h" 00005 #include "cgnames.h" 00006 00007 static int print_identifier (char *name, int nexps, float *exps, 00008 void *user) 00009 { 00010 int n, i; 00011 char term[16], num[33], den[33]; 00012 static char label[] = "MLT@a"; 00013 00014 if (nexps <= 0) { 00015 puts (name); 00016 return 0; 00017 } 00018 printf ("%-32s", name); 00019 num[0] = den[0] = 0; 00020 for (n = 0; n < nexps; n++) { 00021 i = (int)exps[n]; 00022 if (i) { 00023 if (abs(i) > 1) 00024 sprintf (term, "%c^%d", label[n], abs(i)); 00025 else 00026 sprintf (term, "%c", label[n]); 00027 if (i < 0) 00028 strcat (den, term); 00029 else 00030 strcat (num, term); 00031 } 00032 } 00033 if (!num[0]) strcpy (num, "1"); 00034 printf ("%s", num); 00035 if (den[0]) printf (" / %s", den); 00036 putchar ('\n'); 00037 return 0; 00038 } 00039 00040 int main () 00041 { 00042 cg_enum_identifier (print_identifier, NULL); 00043 }