Chinaunix首页 | 论坛 | 博客
  • 博客访问: 38563
  • 博文数量: 64
  • 博客积分: 2640
  • 博客等级: 少校
  • 技术积分: 670
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-26 13:15
文章分类
文章存档

2010年(64)

我的朋友
最近访客

分类: C/C++

2010-01-26 13:40:34

2008-10-31 20:21

#include<iostream>
#include<cstring>
using namespace std;
void Output(char* mid,char* last,int ms,int me,int ls,int le);
int main(void){
    char* mid = new char[10];
    char* last = new char[10];
   
    cin>>mid>>last;
    int len = strlen(mid);
   
    Output(mid,last,0,len-1,0,len-1);
   
    system("pause");
    return 0;
}
void Output(char* mid,char* last,int ms,int me,int ls,int le){
     if(ls>le) return;
     if(le==ls){
        cout<<last[ls];
        return;
     }
   
     int i;
     for(i=ms;i<=me;i++)
         if(mid[i]==last[le]) break;
    
     cout<<last[le];
    
     Output(mid,last,ms,i-1,ls,ls+i-ms-1);
     Output(mid,last,i+1,me,le-me+i,le-1);
}


阅读(212) | 评论(0) | 转发(0) |
0

上一篇:快速幂取模

下一篇:对AOE网求关键路径

给主人留下些什么吧!~~