#include #include void normalize (char *s) { int i = 0, j = 0; while (s[i] == ' ') i++; for (;s[i];) { while (s[i]==' ' && strchr("{}[](),;.: ",s[i+1])) i++; switch (s[i]) { case '{': case '[': s[i] = '('; break; case '}': case ']': s[i] = ')'; break; case ';': s[i] = ','; }; s[j++] = s[i]; if (strchr("(),.:",s[i++])) while (s[i]==' ') i++; } s[j] = 0; if (j>0 && s[j-1]==' ') s[j-1] = 0; } bool equal (char *s1, char *s2) { normalize(s1); normalize(s2); return stricmp(s1, s2) == 0; } void main () { FILE *f, *g; f = fopen("probc.in", "r"); g = fopen("probc.out", "w"); int n; fscanf(f, "%d\n", &n); for (int i=1; i<=n; i++) { char s1[1024], s2[1024]; fgets(s1, 1024, f); fgets(s2, 1024, f); int n1 = strlen(s1) - 1; int n2 = strlen(s2) - 1; if (s1[n1]=='\n') s1[n1]=0; if (s2[n2]=='\n') s2[n2]=0; fprintf(g, "Data Set %d: %s\n\n", i, equal(s1,s2) ? "equal" : "not equal"); } fclose(f); fclose(g); }