#include <iostream>
#include <fstream>
#include <vector>
#include <stdlib.h>
#include <string>
using namespace std;
vector <string> TC (int &m){
vector <string> TC(10);
TC[2]="abc";
TC[3]="def";
TC[4]="ghi";
TC[5]="jkl";
TC[6]="mno";
TC[7]="pqrs";
TC[8]="tuv";
TC[9]="wxyz";
return TC[m];
}
void borrar(vector <string> &CPF,int k){
for (int i=k;i<CPF.size()-1;i++)
CPF[i]=CPF[i+1];
CPF.pop_back();
}
vector <string> recursion(vector <int> &CD, vector <string> &CP,int j){
vector <string> CPF;
if(j==1){ //CASO TRIVIAL
for (int i=0;i<CP.size();i++){
string aux=TC(CD[i]);
for (int k=0;k<aux.size();k++)
if (CP[i][0]==aux[k]){
CPF.push_back(CP[i]);
break;
}
}
return CPF;
}
else { //CASO NO TRIVIAL
CPF=recursion (CD,CP,j-1);
for (int i=0;i<CPF.size();i++){
string aux2=TC(CD[i]);
for (int k=0;k<aux2.size();k++)
if(CPF[i][j-1]==aux2[k])
break;
else {
borrar(CPF,i);
break;
}
}
return CPF;
}
}
int main(int argc,char *argv[]){
ifstream f1(argv[1]);
int n;
f1 >> n;
vector <int> CD(n);
for (int i=0;i<n;i++) f1 >> CD[i];
vector <string> CP;
while(!f1.eof()){
string s;
f1 >> s;
CP.push_back(s);
}
vector <string> CPF;
CPF=recursion(CD,CP,n);
ofstream f2(argv[2]);
for (int i=0;i<CPF.size();i++)
f2 << CPF[i] << endl;
return 0;
}
conversion from `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to non-scalar type `std::vector<std::string, std::allocator<std::string> >' requested ---> en la primera funcion, la funcion TC me da este error al hacer el return (linea 19)
conversion from `std::vector<std::string, std::allocator<std::string> >' to non-scalar type `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' requested ---> dentro de la funcion recursion, en caso trivial y no trivial respectivamnt al asignar al string aux=TC(CD
) (lineas 34 y 47)