-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoxAndMp3Easy.cpp
More file actions
107 lines (102 loc) · 4.15 KB
/
FoxAndMp3Easy.cpp
File metadata and controls
107 lines (102 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <bits/stdc++.h>
using namespace std;
class FoxAndMp3Easy {
public:
vector<string> playList(int n) {
vector<string> ret;
vector<string> v;
string s;
int i;
for (i = 1; i <= n; i++) {
stringstream ss;
ss << i;
s.erase();
s = ss.str();
s += ".mp3";
v.push_back(s);
}
sort(v.begin(), v.end());
for (i = 0; i < 50 && i < v.size(); i++) {
ret.push_back(v[i]);
}
return ret;
}
// BEGIN CUT HERE
public:
void run_test(int Case) {
if ((Case == -1) || (Case == 0)) test_case_0();
if ((Case == -1) || (Case == 1)) test_case_1();
if ((Case == -1) || (Case == 2)) test_case_2();
if ((Case == -1) || (Case == 3)) test_case_3();
if ((Case == -1) || (Case == 4)) test_case_4();
}
private:
template <typename T>
string print_array(const vector<T>& V) {
ostringstream os;
os << "{ ";
for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\",";
os << " }";
return os.str();
}
void verify_case(int Case, const vector<string>& Expected, const vector<string>& Received) {
cerr << "Test Case #" << Case << "...";
if (Expected == Received)
cerr << "PASSED" << endl;
else {
cerr << "FAILED" << endl;
cerr << "\tExpected: " << print_array(Expected) << endl;
cerr << "\tReceived: " << print_array(Received) << endl;
}
}
void test_case_0() {
int Arg0 = 3;
string Arr1[] = {"1.mp3", "2.mp3", "3.mp3"};
vector<string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
verify_case(0, Arg1, playList(Arg0));
}
void test_case_1() {
int Arg0 = 10;
string Arr1[] = {"1.mp3", "10.mp3", "2.mp3", "3.mp3", "4.mp3", "5.mp3", "6.mp3", "7.mp3", "8.mp3", "9.mp3"};
vector<string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
verify_case(1, Arg1, playList(Arg0));
}
void test_case_2() {
int Arg0 = 16;
string Arr1[] = {"1.mp3", "10.mp3", "11.mp3", "12.mp3", "13.mp3", "14.mp3", "15.mp3", "16.mp3",
"2.mp3", "3.mp3", "4.mp3", "5.mp3", "6.mp3", "7.mp3", "8.mp3", "9.mp3"};
vector<string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
verify_case(2, Arg1, playList(Arg0));
}
void test_case_3() {
int Arg0 = 32;
string Arr1[] = {"1.mp3", "10.mp3", "11.mp3", "12.mp3", "13.mp3", "14.mp3", "15.mp3", "16.mp3",
"17.mp3", "18.mp3", "19.mp3", "2.mp3", "20.mp3", "21.mp3", "22.mp3", "23.mp3",
"24.mp3", "25.mp3", "26.mp3", "27.mp3", "28.mp3", "29.mp3", "3.mp3", "30.mp3",
"31.mp3", "32.mp3", "4.mp3", "5.mp3", "6.mp3", "7.mp3", "8.mp3", "9.mp3"};
vector<string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
verify_case(3, Arg1, playList(Arg0));
}
void test_case_4() {
int Arg0 = 109;
string Arr1[] = {"1.mp3", "10.mp3", "100.mp3", "101.mp3", "102.mp3", "103.mp3", "104.mp3", "105.mp3",
"106.mp3", "107.mp3", "108.mp3", "109.mp3", "11.mp3", "12.mp3", "13.mp3", "14.mp3",
"15.mp3", "16.mp3", "17.mp3", "18.mp3", "19.mp3", "2.mp3", "20.mp3", "21.mp3",
"22.mp3", "23.mp3", "24.mp3", "25.mp3", "26.mp3", "27.mp3", "28.mp3", "29.mp3",
"3.mp3", "30.mp3", "31.mp3", "32.mp3", "33.mp3", "34.mp3", "35.mp3", "36.mp3",
"37.mp3", "38.mp3", "39.mp3", "4.mp3", "40.mp3", "41.mp3", "42.mp3", "43.mp3",
"44.mp3", "45.mp3"};
vector<string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
verify_case(4, Arg1, playList(Arg0));
}
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
FoxAndMp3Easy ___test;
___test.run_test(-1);
int gbase;
cin >> gbase; // erase this line if you are not using dev-cpp! :)
return 0;
}
// END CUT HERE