Sekvenční algoritmy “all_of”, “any_of” a “none_of”

{“https:\/\/www.jdoodle.com\/a\/bRj?format=text”:”#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nint main() {\n vector<int> data = { 1, 2, 3, 4, 5, 6, 7 , 8, 9, 10 };\n \n bool result1 = all_of(data.begin(), data.end(), [](int n) { return n > 5; });\n bool result2 = all_of(data.begin(), data.end(), [](int n) { return n < 100; });\n \n cout << boolalpha;\n cout << "Jsou v\u0161echna \u010d\u00edsla > 5: " << result1 << endl;\n cout << "Jsou v\u0161echna \u010d\u00edsla < 100: " << result2 << endl;\n\n return 0;\n}\n”,”https:\/\/www.jdoodle.com\/a\/bRm?format=text”:”#include <iostream>\r\n#include <vector>\r\n#include <algorithm>\r\nusing namespace std;\r\nint main() {\r\n vector<int> data = { 1, 2, 3, 4, 5, 6, 7 , 8, 9, 10 };\r\n \r\n bool result1 = any_of(data.begin(), data.end(), [](int n) { return n % 3 == 0; });\r\n bool result2 = any_of(data.begin(), data.end(), [](int n) { return n % 11 == 0; });\r\n \r\n cout << boolalpha;\r\n cout << "Je n\u011bjak\u00e9 \u010d\u00edslo d\u011bliteln\u00e9 \u010d\u00edslem 3: " << result1 << endl;\r\n cout << "Je n\u011bjak\u00e9 \u010d\u00edslo d\u011bliteln\u00e9 \u010d\u00edslem 11: " << result2 << endl;\r\n return 0;\r\n}”,”https:\/\/www.jdoodle.com\/a\/bRn?format=text”:”#include <iostream>\r\n#include <vector>\r\n#include <algorithm>\r\nusing namespace std;\r\nint main() {\r\n vector<int> data = { 1, 2, 3, 4, 5, 6, 7 , 8, 9, 10 };\r\n \r\n bool result1 = none_of(data.begin(), data.end(), [](int n) { return n > 5; });\r\n bool result2 = none_of(data.begin(), data.end(), [](int n) { return n > 100; });\r\n \r\n cout << boolalpha;\r\n cout << "Nen\u00ed \u017e\u00e1dn\u00e9 \u010d\u00edslo > 5: " << result1 << endl;\r\n cout << "Nen\u00ed \u017e\u00e1dn\u00e9 \u010d\u00edslo > 100: " << result2 << endl;\r\n return 0;\r\n}”}


Sekvenční algoritmy “all_of”, “any_of” a “none_of”
Ohodnoťte tento článek