Untitled
unknown
c_cpp
2 years ago
1.6 kB
5
Indexable
#include <stdio.h> #include <string.h> int main(){ char s[1001]; char k[] = "under construction"; char name[100][31]; int len = strlen(k), index = 0, mode = 0; const char *d = ":,"; while(gets(s) != NULL){ char *p; p = strtok(s, d); mode = 0; while(p != NULL){ if(mode == 0) strcpy(name[index], p); if(mode == 1){ int j = 0; for(int i = 0; i < strlen(p); i++){ if(p[i] == k[j] || p[i] == (k[j]+'A'-'a') || p[i] == (k[j]+'a'-'A')){ j++; if(j == len) index++; } else if(j != 0 && (p[i] != k[j] && p[i] != (k[j]+'A'-'a') && p[i] != (k[j]+'a'-'A'))) j = 0; } } p = strtok(NULL, d); if(mode == 1) mode = 0; else mode = 1; } } char tmp[100][31]; for(int i = 0; i < index; i++){ if(name[i][0] == ' '){ strncpy(tmp[i], name[i]+1, strlen(name[i])); } else{ strcpy(tmp[i], name[i]); } } int check = 0, ans[101]; for(int i = 0; i < index; i++){ ans[i] = i; } for(int i = 0; i < index; i++){ for(int j = 0; j < index; j++){ if(i == j) continue; if(ans[j] == -1 && strcmp(tmp[i], tmp[j]) == 0){ check = 1; } } if(check == 0){ printf("%s\n", tmp[i]); ans[i] = -1; } else check = 0; } }
Editor is loading...