Programming Ability Test Study 10-3. String reverse order (15)

Source: Internet
Author: User
10-3. String reverse order (15) time limit MS Memory limit 65536 KB code length limit 8000 B program standard author Bai Honghuan (Zhejiang University)

Enter a string, reverse the string, and output the string after the reverse order.

Input format:

Enter a non-empty string with a carriage return ending in a row that is not longer than 80 characters long.

Output format:

Prints the string after the reverse order in a row.

Input Sample:
Hello world!
Sample output:
!dlrow Olleh





#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void swap (int a,int B,char *a)
{
Char Temp;int i,j;
for (i=a,j=b;i<=j;i++,j--)
{
Temp=a[i];
A[I]=A[J];
A[j]=temp;
}
}
int main ()
{
Char omg[101];
memset (omg,0,sizeof (OMG));
int N;
Gets (OMG);
scanf ("%d", &n);
if (N>=strlen (OMG)) N=n%strlen (OMG);

Swap (0,N-1,OMG);
Swap (N,strlen (OMG) -1,OMG);
Swap (0,strlen (OMG) -1,OMG);

Puts (OMG);
return 0;
}

Programming Ability Test Study 10-3. String reverse order (15)

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.