/* name.c Corporate name changing program -- string example by:Steven Skiena begun: January 28, 2002 revised: July 3, 2002 */ /* Copyright 2003 by Steven S. Skiena; all rights reserved. Permission is granted for use in non-commerical applications provided this copyright notice remains intact and unchanged. This program appears in my book: "Programming Challenges: The Programming Contest Training Manual" by Steven Skiena and Miguel Revilla, Springer-Verlag, New York 2003. See our website www.programming-challenges.com for additional information. This book can be ordered from Amazon.com at http://www.amazon.com/exec/obidos/ASIN/0387001638/thealgorithmrepo/ */ #include #include #define MAXLEN 1001 /* longest possible string */ #define MAXCHANGES 101 /* maximum number of name changes */ typedef char string[MAXLEN]; string mergers[MAXCHANGES][2]; /* store before/after corporate names */ int nmergers; /* the number of different name changes */ read_changes() { int i; /* counter */ scanf("%d\n",&nmergers); for (i=0; i= ylen) for (i=(pos+xlen); i<=slen; i++) s[i+(ylen-xlen)] = s[i]; else for (i=slen; i>=(pos+xlen); i--) s[i+(ylen-xlen)] = s[i]; for (i=0; i