Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<set>
  4. #include<math.h>
  5. #include<algorithm>
  6. #include<map>
  7. #include <string>
  8. #include <stack>
  9. #include <ctime>
  10. #include <cstdio>
  11. #include <fstream>
  12. using namespace std;
  13. typedef long long ll;
  14.  
  15. int detect(string s, vector<string> &ar) {
  16. int ans = 0;
  17. for (int i = 0; i < ar.size(); i++) {
  18. if (s.find(ar[i]) != string::npos) {
  19. //cout << "s = " << s << " ar[i] = " << ar[i] << endl;
  20. ans++;
  21. }
  22. }
  23. return ans;
  24. }
  25.  
  26. int main() {
  27. ios_base::sync_with_stdio(false);
  28. cin.tie(0);
  29. cout.tie(0);
  30. vector<string> arr_cp = { "int main(", "int main (" , "#include" , "using namespace std", "vector<", "ios_base::" , "#ifdef", "typedef", "iostream::", "#define"
  31. , "cin >>", "cout <<"};
  32. vector<string> arr_pas = { "end.", ":=" , "procedure", "var", "end;"};
  33. vector<string> arr_pyth = { "def ", "in range", "sys.stdin.close()", "sys.stdout.close()", "sys.stdin", "sys.stdout", "lambda:", "last:"};
  34. ofstream fout("output.txt");
  35. for (int i = 1; i <= 700; i++) {
  36. string num = to_string(i);
  37. ifstream fin(num);
  38. int cnt_cpp = 0;
  39. int cnt_pascal = 0;
  40. int cnt_python = 0;
  41. while (!fin.eof()) {
  42. string s;
  43. getline(fin, s);
  44. cnt_cpp += detect(s, arr_cp);
  45. cnt_pascal += detect(s, arr_pas);
  46. cnt_python += detect(s, arr_pyth);
  47. }
  48. if (cnt_cpp == 0 && cnt_pascal == 0 && cnt_python == 0) {
  49. cout << "All zero i = " << i << endl;
  50. }
  51. if (cnt_cpp > cnt_pascal && cnt_cpp > cnt_python) {
  52. fout << "C++" << endl;
  53. }
  54. else {
  55. if (cnt_python > cnt_cpp && cnt_python > cnt_pascal) {
  56. fout << "Python" << endl;
  57. }
  58. else {
  59. if (cnt_pascal == 0) {
  60. cout << "BUVAET i = " << i << " cnt_cpp = " << cnt_cpp << " cnt_pascal = " << cnt_pascal << " cnt_python = " << cnt_python << endl;
  61. }
  62. else {
  63. fout << "Pascal" << endl;
  64. }
  65. }
  66. }
  67. fin.close();
  68. }
  69. fout.close();
  70. system("pause");
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement