Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Conjuntos - analizar la lógica
/* La siguiente función recibe dos vectores con números y debe retornar true si ambos contienen los mismos números (sin importar repeticiones), false en caso contrario. ¿ES CORRECTA LA LÓGICA? ¿PODRÍAS ENCONTRAR UN CASO EN QUE DE UN RESULTADO INCORRECTO? */ #include <iostream> #include <vector> #include <set> using namespace std; bool mismosElementos(vector<int> v1, vector<int> v2) { set<int> elementos1; set<int> elementos2; for (int numero : v1) { elementos1.insert(numero); } for (int numero : v2) { elementos2.insert(numero); } return elementos1==elementos2; } int main() { if (mismosElementos( {1,2}, {1,1,1,2,3} )) { cout << "tienen los mismos elementos"; } else{ cout << "no coinciden"; } }
run
|
edit
|
history
|
help
0
gcc set_terminate
cache_node.cc
Microsoft - MaxEmployeeAttendence (R repititions - 1st step towards DP.)
First and last Occurence of an Element
TypeSizeTest
Policy based smart pointer
blad-z-obcinaniem-koncowek
project
Parenthesis checker
CPPTemplate