60 likes | 198 Views
LP104: Object-Oriented Programming. Review on lab09. Presentation Project Phase I. April 16, 2014 15:00 – 18:00 C302 (TSA) Each group will be given 10 – 15 minutes. Marking schemes. Q1. Testing cases: 1. 1101 -> 4353 2. FFFFFF -> 16777215 3. 489EAF -> 4759215 4.
E N D
LP104: Object-Oriented Programming Review on lab09
Presentation Project Phase I • April 16, 2014 • 15:00 – 18:00 • C302 (TSA) • Each group will be given 10 – 15 minutes
Marking schemes • Q1. Testing cases: • 1. • 1101 -> 4353 • 2. • FFFFFF -> 16777215 • 3. • 489EAF -> 4759215 • 4. • 35B7D -> 220029 • 5. • ABCD -> 43981 Each testing case counts for 10 points
1.ABC,XYZ,FOOO,YUT,RRR,LLLAU , No. 1 : ABC No. 2 : XYZ No. 3 : FOOO No. 4 : YUT No. 5 : RRR No. 6 : LLLAU 2. ABB,,YYY,,CCC,,DDD ,, No. 1: ABB No. 2: YYY No. 3: CCC No. 4: DDD 3.991;2312;abc;213412; ; No. 1: 991 No. 2: 2312 No. 3: abc No. 4: 213412 No. 5: 4.ABC1DEF1RRT1weriwpri1fs 1 No. 1: ABC No. 2: DEF No. 3: RRT No. 4: weriwpri No. 5: fs 5.sfsfAA4324dsrAA2342AApwrew AA No.0 :sfsf No.1 :4324dsr No.2 :2342 No.3 :pwrew Marking scheme: Each testing case counts for 10 points
Lab 09 • StringtoInt() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 int StringtoInt(string & s) { int tmp = 0; for (unsignedint i = 0; i < s.length(); i++) { if (s[i] >= '0' && s[i] <= '9') tmp = tmp * 16 + (s[i] - '0'); else tmp = tmp * 16 + (s[i] - 'A' + 10); } return tmp; }
Lab 09 • tokenize() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 void tokenize(string &str, string &sub){ string tmp; int i=1; int len; len = sub.length(); string::size_type loc = 0; while(loc!= string::npos ){ loc = str.find(sub,0); tmp = str.substr(0,loc); cout << "No. " << i << " : " << tmp << endl; str.erase(0,loc+len); i++; } }