Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- string work (string in_string)
- {
- int len = in_string.length();
- for (int i = 0; i < len; i++)
- {
- if ((in_string[i] == ',') && (in_string[i + 1] != ' '))
- {
- in_string.replace(i, 1 , ", ");
- len++;
- }
- }
- return in_string;
- }
- int main()
- {
- setlocale(0, "");
- string str1[] = "trolilo";
- string str2[] = "trolilo,2000";
- string str3[] = "";
- if ((work("trolilo") == "trolilo")
- && (work("trolilo,2000") == "trolilo, 2000")
- && (work("trolilo,2,0,0,0") == "trolilo, 2, 0, 0, 0")
- && (work("trolilo,2,0,0,0,") == "trolilo, 2, 0, 0, 0, ")
- && (work("") == ""))
- cout << "Программа работает верно\n";
- else
- cout << "Программа работает не верно\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement