Advertisement
SteelK

Untitled

Mar 21st, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. string work (string in_string)
  7. {
  8.     int len = in_string.length();
  9.    
  10.     for (int i = 0; i < len; i++)
  11.     {
  12.         if ((in_string[i] == ',') && (in_string[i + 1] != ' '))
  13.         {
  14.             in_string.replace(i, 1 , ", ");
  15.             len++;
  16.         }
  17.     }  
  18.     return in_string;
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24.     setlocale(0, "");
  25.    
  26.     string str1[] = "trolilo";
  27.     string str2[] = "trolilo,2000";
  28.     string str3[] = "";
  29.    
  30.     if ((work("trolilo") == "trolilo")
  31.         && (work("trolilo,2000") == "trolilo, 2000")
  32.         && (work("trolilo,2,0,0,0") == "trolilo, 2, 0, 0, 0")
  33.         && (work("trolilo,2,0,0,0,") == "trolilo, 2, 0, 0, 0, ")  
  34.         && (work("") == ""))
  35.         cout << "Программа работает верно\n";
  36.     else
  37.         cout << "Программа работает не верно\n";
  38.    
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement