Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ðàáîòà 1.cpp: îïðåäåëÿåò òî÷êó âõîäà äëÿ êîíñîëüíîãî ïðèëîæåíèÿ.
- //
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- #include <fstream>
- #include <iostream>
- #include <locale.h>
- using namespace std;
- bool isNumber(string s) {
- for (int i = 0; i < (int)s.size(); i++) {
- if (s[i] < '0' || s[i] > '9')
- return false;
- }
- return true;
- }
- void InputNumber(int &NumbertoInput, string queryString = "", int max = -1) {
- if (queryString != "")
- printf("%s", queryString.c_str());
- string input;
- getline(std::cin, input);
- while (!isNumber(input) || input == "") {
- printf("Error...\n%s", queryString.c_str());
- getline(std::cin, input);
- }
- if (max == -1 || atoi(input.c_str()) < max)
- NumbertoInput = atoi(input.c_str());
- else {
- printf("Range error...\n");
- InputNumber(NumbertoInput, queryString, max);
- }
- }
- void InputString(string &StringToInput, string queryString = "") {
- if (queryString != "")
- printf("%s", queryString.c_str());
- getline(std::cin, StringToInput);
- return;
- }
- void InputChar(char &c, string law, string queryString = "") {
- if (queryString != "")
- printf("%s", queryString.c_str());
- string tmpInput;
- InputString(tmpInput);
- bool lawer = false;
- while (!lawer) {
- while (tmpInput.size() != 1)
- InputString(tmpInput, "Error...\n" + queryString);
- for (int i = 0; i < law.size(); i++) {
- if (law[i] == tmpInput[0]) {
- lawer = true;
- break;
- }
- }
- if (!lawer) {
- tmpInput = "qqqqqqqqqqqqqqqqqqq";
- printf("Wrong answer!\n");
- }
- }
- c = tmpInput[0];
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- cout << "Uchenica gruppi" << endl;
- cout << "variant 23" << endl;
- ifstream input("input.txt");
- ifstream text("text.txt");
- ofstream output("output.txt");
- string s;
- getline(input, s);
- int count = 0;
- int k = 0;
- while (true)
- {
- string tmp;
- getline(text, tmp);
- if (tmp == "")
- break;
- for (int i = 0; i < strlen(tmp.c_str());)
- {
- k = 0;
- bool isf = false;
- if (tmp[i] == s[0])
- {
- for (int j = 0; j < strlen(s.c_str()); ++j)
- if (tmp[k++] != s[j])
- {
- isf = true;
- break;
- }
- if (!isf)
- ++count;
- i += strlen(s.c_str()) - 1;
- }
- else {
- ++i;
- }
- }
- }
- output << "Count:" << count;
- cout << "Count:" << count << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement