首页 > 其他 > 详细

Reverse String 1.0

时间:2019-05-12 12:45:30      阅读:114      评论:0      收藏:0      [点我收藏+]

main.cpp

 1 #include <iostream>
 2 #include <conio.h>
 3 
 4 #define CONTENT_SIZE 1048576
 5 using namespace std;
 6 
 7 void proc();
 8 
 9 char src[CONTENT_SIZE];
10 char dst[CONTENT_SIZE];
11 int index = 0;
12 
13 int main() {
14     int n;
15     while ( 1 ) {
16         if ( _kbhit() ) {
17             n = _getch();
18             if ( n == 27 ) //Esc
19                 break;
20             if ( n == 13 ) { //Enter
21                 proc();
22                 continue;
23             }
24             cout << ( char ) n;
25             src[index++] = n;
26         }
27     }
28     return 0;
29 }
30 
31 void proc() {
32     src[index] = \0;
33     dst[index] = \0;
34     for ( int i = 0; i < index; i++ )
35         dst[index - i - 1] = src[i];
36     cout << endl << dst << endl << endl;
37     index = 0;
38 }

技术分享图片

附件1

Reverse String 1.0

原文:https://www.cnblogs.com/rms365/p/10851820.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!