You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
417 B
C++
23 lines
417 B
C++
2 years ago
|
#include <iostream>
|
||
|
#include <string>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
void truncateToDot(string& s) {
|
||
|
s.resize(s.find('.'));
|
||
|
s.shrink_to_fit();
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
std::string a = "cat.dog.mouse.elephant.tiger.lion";
|
||
|
std::string b = "wikipedia.org";
|
||
|
std::string c = ".com";
|
||
|
truncateToDot(a);
|
||
|
truncateToDot(b);
|
||
|
truncateToDot(c);
|
||
|
|
||
|
cout << a << endl
|
||
|
<< b << endl
|
||
|
<< c << endl;
|
||
|
}
|