1-19

xiaoxiao2021-03-06  51

/ *

Writing a function Reverse (s), reverses the characters in the string S.

Use this function to write a program, upside down a character order in a input line

* /

#include

#include

Void Reverse (Char * STR)

{

Char * f_iter = str; char * L_ITER = STR;

CHAR TEMP;

IF (str == '/ 0') return; // essential back directly

While ('/ 0'! = * l_iter) l_iter ;

l_iter--

While (f_iter! = l_iter) {

Temp = * f_iter; * f_iter = * l_iter; * l_iter = TEMP;

f_iter ;

IF (f_iter == l_iter) return;

l_iter--

}

}

Int main (void)

{

Char Aa; 256]; CHARLETTER;

INT i = 0;

AA [0] = '/ 0';

While ((letter = getchar ())! = EOF && letter! = '/ n') {

AA [I] = Letter;

i ;

}

AA [i] = '/ 0';

Reverse (aa);

Printf ("% s", AA);

System ("pause");

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-118152.html

New Post(0)