zoukankan      html  css  js  c++  java
  • zoj 3432 与运算运用

    1. /****************************************************
    2. 该题充分运用与运算的特点,成对消除,单的最后留下
    3. ****************************************************/
    4. #include <stdio.h>
    5. #include <string.h>
    6. #include <algorithm>
    7. using namespace std;
    8. int main()
    9. {
    10. char str1[10], str2[10];
    11. int n;
    12. while(~scanf("%d", &n) )
    13. {
    14. getchar();
    15. gets(str1);
    16. for(int i=0; i<2*n-2; i++)
    17. {
    18. gets(str2);
    19. for(int j=0; j<7; j++)
    20. str1[j] = str1[j] ^ str2[j]; //两个字符串各自与运算,可以判定最后剩下的不成对的一个
    21. }
    22. printf("%s ", str1);
    23. }
    24. }
    25. /*
    26. Description
    27. Alice bought a lot of pairs of socks yesterday. But when she went home, she found that she has lost one of them. Each sock has a name which contains exactly 7 charaters.
    28. Alice wants to know which sock she has lost. Maybe you can help her.
    29. Input
    30. There are multiple cases. The first line containing an integer n (1 <= n <= 1000000) indicates that Alice bought n pairs of socks. For the following 2*n-1 lines, each line is a string with 7 charaters indicating the name of the socks that Alice took back.
    31. Output
    32. The name of the lost sock.
    33. Sample Input
    34. 2
    35. aabcdef
    36. bzyxwvu
    37. bzyxwvu
    38. 4
    39. aqwerty
    40. eas fgh
    41. aqwerty
    42. easdfgh
    43. easdfgh
    44. aqwerty
    45. aqwerty
    46. 2
    47. 0x0abcd
    48. 0ABCDEF
    49. 0x0abcd
    50. Sample Output
    51. aabcdef
    52. eas fgh
    53. 0ABCDEF
    54. */





    附件列表

    • 相关阅读:
      Fedora install chrome
      Ubuntu13.04 安装 chrome
      cjb
      屏蔽视频广告
      tars环境部署
      rpm包安装失败的解决办法
      Java环境变量配置错误
      Protobuf的安装使用
      fpm打包工具
      gcc6.3的安装
    • 原文地址:https://www.cnblogs.com/sober-reflection/p/cd588e8df002561ac9f5a9bfed72c57f.html
    Copyright © 2011-2022 走看看