Final Exam-Programming Question # # #: String insertion

Source: Internet
Author: User

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB,

Describe

The number of characters with two strings of STR and SUBSTR,STR not exceeding 10,SUBSTR is 3. (The number of characters does not include ' + ' at the end of the string.) Insert the substr into the one of the most ASCII characters in Str, and if there are more than one, only the first one is considered.

Input

The input includes several lines , each of which behaves as a set of test data, in the form

STR substr

Output

For each set of test data, the output is inserted after the string.

Sample input
Abcab eee12343 555
Sample output
abceeeab12345553




1#include <iostream>2#include <string>3 intMain ()4 {5     using namespacestd;6     Charstr[ -], substr[4];7      while(Cin >> STR >>substr)8     {9         intMax =0;Ten         CharMaxstr = str[0]; One         intS1 = strlen (str);//find out the actual length of the str,substr array.  A         intS2 =strlen (substr); -         if(S1 >Ten|| S2! =3) -cout <<"error!"<<Endl; the         Else -         { -              for(inti =0; I&LT;S1 +1; i++) -                 if(str[i]>maxstr) { +Maxstr =Str[i]; -Max =i; +                 } A              for(inti =0; I < Max +1; i++) at             { -cout <<Str[i]; -             } -              for(inti =0; i < S2; i++) -cout <<Substr[i]; -              for(inti = max +1; I < S1 +1; i++) incout <<Str[i]; -cout <<Endl; to         } +     } -     return 0; the}

The result is right, but to OJ above is complete error .... However, sooner or later will find the problem, there is great God found the problem, hope to be able to advise, grateful:)

Final Exam-Programming Question # # #: String insertion

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.