Untitled
unknown
plain_text
4 years ago
1.3 kB
3
Indexable
#include<stdio.h> #include<string.h> void loai(char *s1 , char *s2) { char c1[300]; char c2[30]; strcpy(c1,s1); strcpy(c2,s2); char t[300][300]; char t1[300][300]; char *cpy; int i = 0; int j = 0; for(i = 0;i<strlen(c1);i++) { if('A' <= c1[i] && c1[i]<= 'Z') { c1[i]+=32; } } for(i = 0;i<strlen(c2);i++) { if('A' <= c2[i] && c2[i]<= 'Z') { c2[i]+=32; } } i = 0; cpy = strtok(s1, " "); while(cpy != NULL) { strcpy(t[i],cpy); cpy = strtok(NULL, " "); i++; } int d1 = i; cpy = strtok(c1, " "); while(cpy != NULL) { strcpy(t1[j],cpy ); cpy = strtok(NULL, " "); j++; } int d2 = j; cpy = "-1"; for(i = 0;i<d2;i++) { if(strcmp(t1[i],c2) == 0) { strcpy(t[i],cpy); } } int h = 0; char y[300][300]; for(i = 0;i<d2;i++) { if(strcmp(t[i],cpy) != 0) { strcpy(y[h],t[i]); h++; } } for(i = 0;i<h;i++) { printf("%s ", y[i]); } } int main() { int t; scanf("%d", &t); int i; for(i = 1;i<=t;i++) { fflush(stdin); char s1[201]; gets(s1); fflush(stdin); char s2[21]; scanf("%s", s2); fflush(stdin); printf("Test %d: ", i); loai(s1,s2); printf("\n"); } return 0; }
Editor is loading...