Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Conjuntos - Contar caracteres únicos
/*Escribir una función que reciba dos parámetros de tipo string y retorne la cantidad de caracteres únicos que aparecen en ambos strings.*/ #include <iostream> #include <string> #include <set> using namespace std; int unicos(string str1, string str2) { set<char> caracteres; for (char c : str1+str2) { caracteres.insert(c); } return caracteres.size(); } int main() { cout << unicos("a", "sopa") << endl; cout << unicos("manzana", "jugar") << endl; cout << unicos("dolorido", "cebra") << endl; }
run
|
edit
|
history
|
help
0
BinTraversal v2
Vec+Mem+Adv_11
HeapSort
EqualIdentical
Weighted Average
arthi3.cpp
133
Ptrtest
顺序表的实现——动态分配
Elevator