1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include <string>
using namespace std;
int main () {
bool same = true;
string str1, str2;
char arr1[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int arr2[26], arr3[26], ast = 0;
getline(cin, str1);
for (int i = 0; i < 25; i++){
arr2[i] = 0;
arr3[i] = 0;
}
for (int j = 0; j < 25; j++) {
for (int i = 0; i < str1.length() -1; i++) {
if (str1[i] == arr1[j]) {
arr2[j]++;
}
}
}
getline(cin, str2);
for (int j = 0; j < 25; j++) {
for (int i = 0; i < str2.length() -1; i++) {
if (str2[i] == arr1[j]) {
arr3[j]++;
}
else if (str2[i] == '*') {
ast++;
}
}
}
for (int i = 0; i < 25; i++) {
if (arr2[i] != arr3[i]) {
ast--;
if (ast < 0) {
same = false;
}
}
}
if (str1.length() != str2.length()) {
same = false;
}
if (same == true) {
cout << 'A';
}
else {
cout << 'N';
}
cin.get();
return 0;
}
|