zoukankan      html  css  js  c++  java
  • Reverse String 2.0

    main.cpp

     1 #include <iostream>
     2 #include <conio.h>
     3 #include <stdlib.h>
     4 #include <unistd.h>
     5 #include <fstream>
     6 
     7 #define CONTENT_SIZE 1048576
     8 
     9 using namespace std;
    10 
    11 void proc();
    12 
    13 char src[CONTENT_SIZE];
    14 char dst[CONTENT_SIZE];
    15 int index = 0;
    16 
    17 int main() {
    18     string app_home = _pgmptr;//_pgmptr 指向应用自身的完整路径
    19     app_home += "/..";
    20     chdir ( app_home.c_str() );
    21     int n;
    22     while ( 1 ) {
    23         if ( _kbhit() ) {
    24             n = _getch();
    25             if ( n == 27 ) //Esc
    26                 break;
    27             if ( n == 13 ) { //Enter
    28                 proc();
    29                 continue;
    30             }
    31             cout << ( char ) n;
    32             src[index++] = n;
    33         }
    34     }
    35     return 0;
    36 }
    37 
    38 void proc() {
    39     src[index] = '';
    40     dst[index] = '';
    41     for ( int i = 0; i < index; i++ )
    42         dst[index - i - 1] = src[i];
    43     cout << endl << dst << endl << endl;
    44     ofstream ofs ( ".clip.tmp" );
    45     ofs << dst;
    46     ofs.close();
    47     system ( "clip < .clip.tmp" );
    48     index = 0;
    49 }

    附件1

  • 相关阅读:
    [BZOJ3694]最短路
    [Usaco2011 Jan]道路和航线
    洛谷P1443马的遍历
    洛谷P1636学画画
    洛谷P1605走迷宫
    队列&广搜
    数论卷积公式and莫比乌斯反演
    数学之判断素数
    纯数学篇之欧拉定理证明
    筛素数
  • 原文地址:https://www.cnblogs.com/rms365/p/10852072.html
Copyright © 2011-2022 走看看