Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<set>
- #include<math.h>
- #include<algorithm>
- #include<map>
- #include <string>
- #include <stack>
- #include <ctime>
- #include <cstdio>
- #include <fstream>
- using namespace std;
- typedef long long ll;
- int detect(string s, vector<string> &ar) {
- int ans = 0;
- for (int i = 0; i < ar.size(); i++) {
- if (s.find(ar[i]) != string::npos) {
- //cout << "s = " << s << " ar[i] = " << ar[i] << endl;
- ans++;
- }
- }
- return ans;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- vector<string> arr_cp = { "int main(", "int main (" , "#include" , "using namespace std", "vector<", "ios_base::" , "#ifdef", "typedef", "iostream::", "#define"
- , "cin >>", "cout <<"};
- vector<string> arr_pas = { "end.", ":=" , "procedure", "var", "end;"};
- vector<string> arr_pyth = { "def ", "in range", "sys.stdin.close()", "sys.stdout.close()", "sys.stdin", "sys.stdout", "lambda:", "last:"};
- ofstream fout("output.txt");
- for (int i = 1; i <= 700; i++) {
- string num = to_string(i);
- ifstream fin(num);
- int cnt_cpp = 0;
- int cnt_pascal = 0;
- int cnt_python = 0;
- while (!fin.eof()) {
- string s;
- getline(fin, s);
- cnt_cpp += detect(s, arr_cp);
- cnt_pascal += detect(s, arr_pas);
- cnt_python += detect(s, arr_pyth);
- }
- if (cnt_cpp == 0 && cnt_pascal == 0 && cnt_python == 0) {
- cout << "All zero i = " << i << endl;
- }
- if (cnt_cpp > cnt_pascal && cnt_cpp > cnt_python) {
- fout << "C++" << endl;
- }
- else {
- if (cnt_python > cnt_cpp && cnt_python > cnt_pascal) {
- fout << "Python" << endl;
- }
- else {
- if (cnt_pascal == 0) {
- cout << "BUVAET i = " << i << " cnt_cpp = " << cnt_cpp << " cnt_pascal = " << cnt_pascal << " cnt_python = " << cnt_python << endl;
- }
- else {
- fout << "Pascal" << endl;
- }
- }
- }
- fin.close();
- }
- fout.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement