數據結構——行編輯程序

#include<fstream>
#include<string>
#include<iostream>
using namespace std;
string s;
char a[5005];
int p=0;
int main()
{
	int i, len;
	cin >> s;
	len = s.size();
	for (i = 0; i < len; i++)
	{
		if (s[i] == '@')
			p = 0;
		else if (s[i] == '#'&&p>0)
			--p;
		else if (s[i] != '#')
			a[++p] = s[i];
	}
	for (i = 1; i <= p; i++)
	{
		cout << a[i];
	}
	cout << endl;
	system("pause");
	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章