c++字符匹配程序求教

来源:百度知道 编辑:UC知道 时间:2024/05/29 19:50:36
要写一个程序,打开一文本(假设是d:\010.txt.),然后通过其中字符匹配检索并输出
匹配规则是:子程序名,它后面空格后跟个字符串(以aa代替),通过call调用别的程序,但call后有loc 和sub开头的两种不同的模式,子程序以字符串endp结束.
这样的子程序有很多.
要求输出:子程序名 调用的以sub开头的程序名.
例子:
sub01 aa
xxxxxxxxxxxxx
sgdh
call loc 001
dgagag
call sub001
wetay
call sub002
endp
sub02 aa
sggeyheeuueu
call sub003
tweyweueu
call loc002
wywy
endp
等等
输出为sub01:sub001 sub002
sub02:sub003
请说出详细的算法,有程序更好,可追加100分.多谢
PS:希望楼下的不要捣乱...多谢
<br>呼唤高人出现.
飘渺世间天 ,请留个QQ号好吗?程序有些问题

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <cctype>
#include <iterator>
using namespace std;

typedef vector<vector<string> > _2DVec;
typedef string::size_type size_type;

size_type Length(size_type InitLen, size_type iBegPos, const string& strCode)
{
size_type iLength = InitLen;
for(size_type i = iBegPos + InitLen; isdigit(strCode[i]); ++i, ++iLength);

return iLength;
}

void SubSearch(const string& strCode, _2DVec& vvSupSub)
{
size_type iBegPos = 0;
while((iBegPos = strCode.find("sub", iBegPos)) != string::npos)
{
size_type iSupLen = Length(3, iBegPos, strCode);
string strSup(strCode, iBegPos, iSupLen); // Superior Sub
iBegPos += iSupLen;

vector<string> vSubSub;
vSubSub.push_back(strSup);

size_type