i'm just a beginner in c++
my assignment was to wrote the functions.
i tried to write a main to test it.
but i could call it correctly/.
my assignment was to wrote the functions.
i tried to write a main to test it.
but i could call it correctly/.
Code:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
bool chars(char x)
{
if (((x<=90)&&(x>=65))||((x<=122)&&(x>=97)))
return false;
else return true;
}
int transformCriteria(unsigned int distances[], std::string words1[],std::string words2[],unsigned int nCriteria)
{
int z;
for (int i=0; i<nCriteria;i++)
{
int s1= words1[i].size();
int s2= words2[i].size();
string originalWord1=words1[i];
string originalWord2=words2[i];
words1[i].erase(std::remove_if(words1[i].begin(), words1[i].end(), &chars), words1[i].end());
words2[i].erase(std::remove_if(words2[i].begin(), words2[i].end(), &chars), words2[i].end());
for (int s=0; s<s1; s++)
{
words1[i][s]=words1[i][s]+32;
}
for (int s=0; s<s2; s++)
{
words2[i][s]=words2[i][s]+32;
}
if ((originalWord1!=words1[i])||(originalWord2!=words2[i]))
z++;
}
return z;
}
int main()
{
string n1[3]={ "teacher", "teacher", "teacher2"};
string n2[3]={ "teacher11", "teacher", "teacher22"};
unsigned int q=3;
unsigned int p[]={2,3,4};
cout << transformCriteria(p[], n1[], n2[], q)<< endl;//here is where mistakes happen
}
Comment