Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "string.h"
- #define MAX_LEN 1000
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- char s1[MAX_LEN];
- char s2[MAX_LEN];
- char buf[MAX_LEN];
- int buf_p = 0;
- scanf("%s", s1);
- scanf("%s", s2);
- for (int i = 0; i < strlen(s2); ++i) {
- int count = 0;
- for (int j = 0; j < strlen(s2); ++j) {
- if (s2[i] == s2[j]) {
- ++count;
- }
- if (count > 2) {
- printf("NO");
- return 0;
- }
- }
- int good = 0;
- if (count == 2) good = 1;
- for (int j = 0; j < strlen(s2); ++j) {
- if (s1[j] == s2[i]) {
- good = 1;
- buf[buf_p] = s1[j];
- ++buf_p;
- break;
- }
- }
- if (good != 1) {
- printf("NO");
- return 0;
- }
- }
- printf("%s%s", s2, buf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement