/******************************************* * Section : 15 * Machine No. : N * Roll No. : 19CS100XY * Name : Aritra Hazra * Assignment No : LT-2-EVEN-A * Description : Inverse Mapping of Functions *******************************************/ #include #include #include #define MAX_NAME 100 #define MAX_STRING 100000 // structure to keep function name and all map descriptions typedef struct func { char nameFunc[MAX_NAME]; struct map *arrMap; int numMap; } function; // structure to keep 'character->string' maps of a function typedef struct map { char lhs; char rhs[MAX_STRING]; int len; } mapFunc; // structure to keep example composite function details and input string typedef struct example { struct comp_func *arrCompMap; int numComp; char inputStr[MAX_STRING]; } mapExample; // structure to keep each function and its number of applications within each composite function set typedef struct comp_func { char nameExampleFunc[MAX_NAME]; int numApply; } compositeFunc; // function to return the array position (index) of the searched function if found, otherwise return -1 int findFuncIndex(function *fn, int n, char *name) { int i, idx = -1; for (i=0; i%s", &(arrFunc[i].arrMap[j].lhs), arrFunc[i].arrMap[j].rhs); } } // scanning user inputs: number of example composite functions and their details + input string for applying the example function scanf("%d", &numExample); arrExample = (mapExample *)malloc(numExample * sizeof(mapExample)); for (i=0; i