Reverse string order

Source: Internet
Author: User

Enter a string in reverse order and output the string in reverse order.

Input Format:

Enter a non-empty string that cannot exceed 80 characters and ends with a carriage return.

Output Format:

Output the reverse string in a row.

Input example:
 
Hello world!
Output example:
 
! Dlrow olleh

 

# Include<Stdio. h>Int main (){Char s [81] = { 0 };  // char C;  int I =  0;  do {scanf (  " % C  ", & S [I ++]); /* If (C! = '\ N') {s [I ++] = C ;} */}  while (s [I- 1]! =  '\ n'); I = I- 2; // press enter to take up two characters  while (I >=< SPAN class = "integer"> 0) {printf (  " % C  ", s [I --]);  // I --;} printf (  " \ n  ");  return  0 ;}   

 

 

  1. # Include <stdio. h>
  2. # Include <string. h>
  3. Int main ()
  4. {
  5. Char str1 [81], str2 [82];
  6. Gets (str1 );
  7. For (Int I = strlen (str1)-1; I> = 0; I --)
  8. {
  9. Str2 [strlen (str1)-1-I] = str1 [I]; // The character array is saved separately.
  10. }
  11. Str2 [strlen (str1)] ='\ 0 ';
  12. Puts (str2 );
  13. Return 0;
  14. }

 

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.