Explain Plz:
Posted: Mon Oct 27, 2003 8:14 pm
You mean something of
se laver(thats french though)
exists as a verb???
Suman.
se laver(thats french though)
exists as a verb???
Suman.
I compile and run this fine off my computer, using g++, why does UVA give me a runtime error for this?Code: Select all
/*Learning Portuguese #10197*/ #include <iostream> #include <cstring> #include <cassert> #include <string> using namespace std; #define PORT_O 243 class CPort { public: CPort(); CPort(string, string); ~CPort(); void setVerb(string); void setTransl(string); void setRoot(); void setTv(string); void setKnown(string); string getVerb() const; string getTransl() const; string getRoot() const; string getTv() const; bool getKnown() const; private: string verb, root ,transl , tv; bool known; }; ostream &operator<< (ostream &, const CPort &); int main() { CPort * word; string ve, tr; while(cin >> ve) { cin.get(); cin >> tr; cin.get(); word = new CPort(ve, tr); cout << *word; } // end while return 0; } // end main() CPort::CPort() { verb = ""; transl = ""; } // end default CPort constructor CPort::CPort(string v, string t) { setVerb(v); setTransl(t); } // end explicit CPort constructor CPort::~CPort() { verb = ""; transl = ""; } // end CPort DESTRUCTOR void CPort::setVerb(string v) { verb = v; setKnown(verb); if(getKnown()) setRoot(); } // end setVerb() void CPort::setTransl(string t) { transl = t; } // end setTransl() void CPort::setRoot() { root = verb.substr(0, verb.length() - 2); } // end setRoot() void CPort::setTv(string l) { tv = l; } // end setTv() void CPort::setKnown(string v) { known = true; string ar = "ar"; string er = "er"; string ir = "ir"; string temp; int length; length = v.length(); if((v.substr(length - 2, 2) == ar) || (v.substr(length - 2, 2) == er) || (v.substr(length - 2, 2) == ir)) setTv(v.substr(length - 2, 1)); else known = false; } // end setKnown() string CPort::getVerb() const {return verb;} // end getVerb() string CPort::getTransl() const {return transl;} // end getTransl() string CPort::getRoot() const {return root;} // end getRoot() string CPort::getTv() const {return tv;} // end getTv() bool CPort::getKnown() const {return known;} // end getKnown() ostream &operator<< (ostream & out, const CPort & A) { string temp, eu, tu, ele, vo, eles; char nos[] = {'n', PORT_O, 's', '\0'}; char vos[] = {'v', PORT_O, 's', '\0'}; (A.getTv() == "i") ? tu = "es" : tu = A.getTv() + "s"; (A.getTv() == "i") ? ele = "e" : ele = A.getTv(); (A.getTv() == "i") ? vo = A.getTv() + "s" : vo = A.getTv() + "is"; (A.getTv() == "i") ? eles = "em" : eles = A.getTv() + "m"; if(A.getKnown()) { temp += A.getVerb() + " (to " + A.getTransl() + ")" + "\neu " + A.getRoot() + "o" + "\ntu " + A.getRoot() + tu + "\nele/ela " + A.getRoot() + ele + "\n" + nos + " " + A.getRoot() + A.getTv() + "mos" + "\n" + vos + " " + A.getRoot() + vo + "\neles/elas " + A.getRoot() + eles + "\n\n"; out << temp; } // end if else out << A.getVerb() << " (to " << A.getTransl() << ")" << "\nUnknown conjugation\n\n"; return out; } // end ostream operator<< overload
falar talk
ir sohel
or turjo
i cry
sir pray
tirr con
abcdef do
falar (to talk)
eu falo
tu falas
ele/ela fala
n
Code: Select all
while loop fetching two strings with scanf until eof
show the portuguese verb and the english correspondent
get last char and the tv char into char variables
switch the tv var
case 'a', conj = 1
case 'e', conj = 2
case 'i', conj = 3
default, conj = 0
get the root to a string variable
if last char is not 'r', conj = 0
if conj = 0
show unknow
else if conj = 1 or conj = 2
show 1st or 2nd conjugations
else if conj = 3
show 3rd conjugation
Code: Select all
partir go away
Code: Select all
partir (to go away)
eu parto
tu partes
ele/ela parte
n