错误求调
查看原帖
错误求调
1008234
byk_ALEX楼主2025/7/26 18:03

用了dev-c++,结果在显示屏出现了terminate called after throwing an instance一大堆错误,不知道咋改 代码:

#include<bits/stdc++.h>
using namespace std; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); 
	cout.tie(0);
	int n;
	string a[101], b[101];
	cin >> n; 
//	cout << n << endl;
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
	string s;
	bool flag = 0;
	int first = 0, end = 0;
	cin >> s;
	int e = s.length();
	string s1 = s;
	for(int i = 0; i < e; i++){
//		cout << first << endl; 
	//	cout << i << " ";
		if(s1[i] >= 'a' && s1[i] <= 'z' && flag == 0){
			first = i;
			flag = 1;
			continue;
		}
		if(!(s1[i] >= 'a' && s1[i] <= 'z')){
			end = i - 1;
			flag = 0;
		}
			string w = s1.substr(first, end - first);
		//	cout << w << endl;
		//	cout << first << endl;
			bool flag1 = 0;
			for(int j = 0; j < n; j++){
				if(w == a[j]){
					s.replace(first, end - first + 1, b[i]);
					flag1 = 1;
				}
			}
		if(flag1 == 0){
			s.replace(first, end - first + 1, "UNK");
		}
	//	cout << s << endl;
	}
	cout << s;
	return 0; 
}
2025/7/26 18:03
加载中...