Advertisement
filashkov

Untitled

Oct 13th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <iostream>
  5. #include <string.h>
  6.  
  7. using namespace std;
  8.  
  9. static void
  10. optimize(char *s, int n)
  11. {
  12.     for (int i = 0; i < s; i++) {
  13.         if (s[i] == '.') {
  14.             if (s[i + 1] == '.') {
  15.                 if (s[i + 2] == '/') {
  16.                     s[i] = '\0';
  17.                     s[i + 1] = '\0';
  18.                     s[i + 2] = '\0';
  19.                     for (int j = i - 1; j >= 1; j++) {
  20.                         if (s[j - 1] == '/') {
  21.                             s[j - 1] = '\0';
  22.                             break;
  23.                         }
  24.                         s[j - 1] = '\0';
  25.                     }
  26.                 }
  27.             } else if (s[i + 1] == '/') {
  28.                 s[i] = '\0';
  29.                 s[i + 1] = '\0';
  30.             }
  31.         }
  32.     }
  33. }
  34.  
  35. char *
  36. relativize_path(const char *path1, const char *path2)
  37. {
  38.     char result[MAX_PATH + 7], char temp[MAX_PATH + 7];
  39.     strcpy(temp, path1);
  40.     strcpy(result, path2);
  41.     int n1 = strlen(result);
  42.     for (int i = 0; i < n1; i++) {
  43.         if (temp[)
  44.     }
  45.  
  46. }
  47.  
  48. int
  49. main()
  50. {
  51.     char s1[MAX_PATH + 7], s2[MAX_PATH + 7];
  52.     cin >> s1 >> s2;
  53.     cout << relativize_path(s1, s2) << endl;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement