Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int main() {
- std::vector<std::string> url;
- int n;
- std::cout << "Введите количество строк: " << std::endl;
- std::cin >> n;
- for (int i = 0; i < n; i++) {
- std::string buf;
- std::cin >> buf;
- url.push_back(buf);
- }
- for (int i = 0; i < n; i++) {
- std::cout << "String № " << i << std::endl;
- std::vector<std::string> buf;
- int pos = url[i].find(':');
- if (pos == -1) {
- std::cout << "Protocol: " << "http" << std::endl;
- } else {
- std::cout << "Protocol: " << url[i].substr(0, pos) << std::endl;
- url[i].erase(0, pos + 3);
- }
- pos = url[i].find(':');
- if (pos != -1) {
- std::cout << "Host: " << url[i].substr(0, pos) << std::endl;
- url[i].erase(0, pos + 1);
- std::cout << "Port: " << url[i].substr(0, 2) << std::endl;
- url[i].erase(0, 4);
- }
- if (pos == -1) {
- std::cout << "Port: " << 80 << std::endl;
- pos = url[i].find('/');
- std::cout << "Host: " << url[i].substr(0, pos) << std::endl;
- if (pos != -1) {
- url[i].erase(0, pos + 1);
- if (url[i].size() != 0) {
- std::cout << "Page: " << url[i].substr(0, url[i].size()) << std::endl;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement