C language · Recursive inverted character array

Source: Internet
Author: User
Tags array length

Algorithm improves recursive inverted character array time limit: 1.0s memory limit: 512.0MBThe problem description completes a recursive program, inverted character array. and print the implementation process
The recursive logic is:
When the character length equals 1 o'clock, return directly
Otherwise, replace the first two characters, in the recursive inverted character array of the remainder of the input format character array length and the array output format in the solution process, print character array changes.
The last empty line, at the end of the program, prints the elements of the array after it is inverted. Sample input
Sample ABCDE
Sample A

Sample output

Sample 1EBCDAEDCBAEDCBA
Sample 2a

Author notes: Compile to the result according to the topic is no problem, but the submission however, the egg hurts.
1#include <stdio.h>2 voidDaozhi (intBeginintEndChars[]) {3     if(Begin>=end)return;4     Else{5         Chartemp;6temp =S[begin];7S[begin] =S[end];8S[end] =temp;9printf"%s\n", s);TenDaozhi (begin+1, end-1, s); One     } A      - } - intMain () { the     intLen; -     Chars[10000]; -scanf"%d%s",&len,&s); -Daozhi (0, len-1, s); +      for(intI=0; i<len;i++){ -printf"%c", S[i]); +     } A     return 0; at}

C language · Recursive inverted character array

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.