Advertisement
wojiaocbj

Untitled

Jun 14th, 2022
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.31 KB | None | 0 0
  1. /*
  2.  Author: 曹北健
  3.  Result: WA    Submission_id: 4531247
  4.  Created at: Tue Jun 14 2022 19:57:03 GMT+0800 (China Standard Time)
  5.  Problem_id: 4646    Time: 3    Memory: 1652
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #include <ctype.h>
  11. #include <string.h>
  12. #pragma warning(disable:4996)
  13. typedef long long LL;
  14. char s1[114514] = { 0 }, s2[114514] = { 0 };
  15. char data1[128][128] = { 0 };
  16. char common[128][128] = { 0 };
  17. int cmparr(const void *p, const void *q){
  18.     return strcmp((char *)p, (char *)q);
  19. }
  20. int main(){
  21. #ifdef _DEBUG
  22.     //fclose(stdin);
  23.     freopen("../../../in.txt", "rb", stdin);
  24.     //freopen("../../../out.txt", "w", stdout);
  25. #endif // _DEBUG
  26.     char tmp[128] = { 0 }, buf1[128] = { 0 };
  27.     char *end, *p;
  28.     int l, k1 = 0, i, k2 = 0, j, flag = 0;
  29.     fgets(s1, 114514, stdin);
  30.     end = strrchr(s1, '}');
  31.     *end = 0;
  32.     p = strtok(s1 + 1, ",");
  33.     while(p){
  34.         l = 0;
  35.         //strcpy(data1[k1], p);
  36.         for(i = 0; p[i]; i++){
  37.             if(isalpha(p[i])){
  38.                 data1[k1][l] = p[i];
  39.                 l++;
  40.             }
  41.         }
  42.         p = strtok(0, ",");
  43.         k1++;
  44.     }
  45.     fgets(s2, 114514, stdin);
  46.     end = strrchr(s2, '}');
  47.     *end = 0;
  48.     p = strtok(s2 + 1, ",");
  49.     while(p){
  50.         //strcpy(tmp, p);
  51.         l = 0;
  52.         memset(tmp, 0, 128);
  53.         for(i = 0; p[i]; i++){
  54.             if(isalpha(p[i])){
  55.                 tmp[l] = p[i];
  56.                 l++;
  57.             }
  58.         }
  59.         for(i = 0; i < k1; i++){
  60.             if(!strcmp(tmp, data1[i])){
  61.                 flag = 0;
  62.                 for(j = 0; j < k2; j++){
  63.                     if(!strcmp(tmp,common[j])){
  64.                         flag = 1;
  65.                         break;
  66.                     }
  67.                 }
  68.                 if(!flag){
  69.                     strcpy(common[k2], tmp);
  70.                     k2++;
  71.                 }        
  72.                 break;
  73.             }
  74.         }
  75.         p = strtok(0, ",");
  76.     }
  77.     if(k2){
  78.         qsort(common, k2, 128, cmparr);
  79.         for(i = 0; i < k2; i++){
  80.             printf("%s ", common[i]);
  81.         }
  82.     }
  83.     else{
  84.         puts("NONE");
  85.     }
  86. #ifdef _DEBUG
  87.     freopen("CON", "rb", stdin);
  88.     //freopen("CON", "w", stdout);
  89.     system("pause");
  90. #endif // _DEBUG
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement