View Code of Problem 105

#include<iostream>
#include<iomanip>
#include<string>

using namespace std;

int main() {
	string r;
	while (cin >> r) {
		if (r == "END") {
			return 0;
		}

		int m;
		string temp;
		cin >> m;
		int flag = 0;
		for (int i = 1; i <= m; ++i) {
			cin >> temp;
			if (temp == r) {
				cout << i << " OK!" << endl;
			}
			else if (temp.size() == r.size()) {
				int j;
				for (j = 0; j < temp.size(); ++j) {
					if (temp[j] != r[j]) {
						cout << i << " " << j + 1 << " change " << r[j] << endl;
						break;
					}
				}
			}
			else if (temp.size() < r.size()) {
				int j;
				for (j = 0; j < temp.size(); ++j) {
					if (temp[j] != r[j]) {
						cout << i << " " << j + 1 << " insert " << r[j] << endl;
						break;
					}
				}
				if (j == temp.size()) {
					cout << i << " " << j + 1 << " insert " << r[j] << endl;
				}
			}
			else if (temp.size() > r.size()) {
				int j;
				for (j = 0; j < r.size(); ++j) {
					if (temp[j] != r[j]) {
						cout << i << " " << j + 1 << " delete " << temp[j] << endl;
						break;
					}
				}
				if (j == r.size()) {
					cout << i << " " << j + 1 << " delete " << temp[j] << endl;
				}
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 105