Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <unordered_map>
- #include <vector>
- using namespace std;
- int main() {
- FILE *f, *d;
- f = fopen("in.txt", "r");
- d = fopen("OUT.TXT", "w");
- unordered_map<char, int> map;
- vector<char> str1;
- char sym;
- bool map_work = true;
- while (true) {
- if (feof(f)) { break; }
- sym = fgetc(f);
- cout << sym << endl;
- if (sym == '\n') {
- map_work = false;
- }
- if (map_work) {
- if (map.find(sym) == map.end()) {
- map.insert(pair<char, int>(sym, 1));
- str1.push_back(sym);
- } else { map[sym] += 1; }
- } else if (map.find(sym) != map.end()) { map[sym] -= 1; }
- }
- bool good = true;
- for (int i = 0; i < str1.size(); i++) {
- if (map[str1[i]] > 0) {
- good = false;
- break;
- };
- }
- if (good) { fprintf(d, "Да"); }
- else { fprintf(d, "Нет"); }
- fclose(f);
- fclose(d);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement