CodeForces 245B -- Internet Address

Source: Internet
Author: User

It seems like a simple question, but there are many errors.

The requirement for a question is to convert a string of letters into a URL, in the format of http (ftp): // xxx.ru/xxxx. it seems simple, but it is easy to make mistakes.

When I first started searching, I searched for the first group of http/ftp, and then searched for the first ru to form the website. However, an error was reported. The following is an example: httpruc

Therefore, you cannot search for the first website. That is to say, it is illegal to avoid having nothing before. ru. Note that http is a four-character ftp with only three characters, so it cannot be fixed ..

 

# Include <iostream> # include <string> using namespace std; int main () {string tar, res; string tarstack; int propos = 0, ctpos = 0; cin> tar; if (tar [0] = 'H') {tarstack = "http";} if (tar [0] = 'F ') {tarstack = "ftp";} ctpos = tar. find ("ru", tarstack. length () + 1); // 5 is not acceptable. Inertial thinking cannot be performed if (tar [0] = 'H') {cout <tarstack <": // "; for (int I = 4; I <ctpos; I ++) {cout <tar [I] ;}cout <". ru "; if (ctpos + 2 = tar. length () cout <endl; else {cout <"/"; for (int I = ctpos + 2; I <tar. length (); I ++) {cout <tar [I];} cout <endl ;}} else if (tar [0] = 'F ') {cout <tarstack <": //"; for (int I = 3; I <ctpos; I ++) {cout <tar [I];} cout <". ru "; if (ctpos + 2 = tar. length () cout <endl; else {cout <"/"; for (int I = ctpos + 2; I <tar. length (); I ++) {cout <tar [I] ;}cout <endl ;}return 0 ;}// example: httpruhhphhhpuhruruhhpruhhphruhhru

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.