Advertisement
SteelK

Untitled

Mar 10th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. char * newstr(const char * newtemp)
  5. {
  6.     int i = 0, j = 0, N;
  7.     N = strlen(newtemp) + 1;
  8.     char *str = new char[N];
  9.     strcpy(str, newtemp);
  10.     char* fin_string = new char[N];
  11.     while (i != N)
  12.     {
  13.         if (str[i] != '<')
  14.         {
  15.             fin_string[j] = str[i];
  16.             i++;
  17.             j++;
  18.         }
  19.         else
  20.         {
  21.             fin_string[j] = str[i];
  22.             i++;
  23.             j++;
  24.             while (str[i] != '>')
  25.                 i++;
  26.             fin_string[j] = str[i];
  27.             i++;
  28.             j++;
  29.         }
  30.     }
  31.     return fin_string;
  32.     delete[]str;
  33. }
  34.  
  35. int main()
  36. {
  37.     if ((strcmp(newstr("Viktoria"), "Viktoria")) || (strcmp(newstr("<kuku>"), "<>")) || (strcmp(newstr("<>"), "<>")) || (strcmp(newstr(""), "")))
  38.     {
  39.         cout << "bad" << endl;;
  40.         return 1;
  41.     }
  42.  
  43.    cout << "Good" << endl;
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement