Nine degrees OJ 1525 substring reverse print

Source: Internet
Author: User

Topic 1525: Sub-string Reverse print

time limit:1 seconds

Memory limit:128 MB

Special question: No

submitted:2404

Resolution:388

Title Description:

Xiaoming has a lot of string cards, each string contains a number of consecutive spaces, and these cards in the process of printing each substring of the string is printed in reverse, now trouble you to help Xiao Ming the strings in the string correction, and in order to make the card beautiful, compressed in which the continuous space of 1.

Input:

The input contains multiple test cases, and the first line of each test case is a positive integer n,1=<n<=100000 that represents the length of the string on the card. The second line enters a string of length n (the string contains only lowercase letters and spaces). When n is 0 o'clock, represents the input end.

Output:

For each test case, output the corrected string as required.

Sample input:
3ABC13ABC   EFG Hij
Sample output:
CBACBA GFE Jih
source :
2012 Google Campus Recruitment written question
#include <stdio.h> #include <string.h> #define MAX 100000+10char S[max];char tmp[max];int main () {int n;        while (~SCANF ("%d", &n)) {if (n==0) return 0;        while (GetChar ()! = ' \ n ');        Gets (s);        int Len=strlen (s);        int i=0;            while (i<len) {int j=0;                while (i<len&&s[i]== ") {i++;            j + +;            } if (j>0) printf ("");            j=0;                while (i<len&&s[i]!= ") {tmp[j++]=s[i];            i++;                    } if (j>0) {for (int p=0,q=j-1;p<q;++p,--q) {                    Char T=tmp[p];                    TMP[P]=TMP[Q];                tmp[q]=t;                } tmp[j]= ' + ';            printf ("%s", TMP);    }} printf ("\ n"); } return 0;} /**************************problem:1525 User:kirchhoff language:c result:accepted time:40 ms memory:1112 kb****************************************************************/



Nine degrees OJ 1525 substring reverse print

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.