-
Notifications
You must be signed in to change notification settings - Fork 0
/
str2num.cpp
executable file
·46 lines (41 loc) · 963 Bytes
/
str2num.cpp
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
#include <iostream>
#include <vector>
using namespace std;
class str2num
{
private:
/* data */
const int MAX_WIDTH = 100;
public:
str2num(/* args */);
~str2num();
vector<int> numberOfLines(vector<int>& widths, string s){
int lines = 1;
int width = 0;
for (auto & c : s) {
cout << c-'a' << endl;
int need = widths[c - 'a'];
width += need;
if (width > str2num::MAX_WIDTH) {
lines++;
width = need;
}
}
return {lines, width};
};
};
str2num::str2num(/* args */)
{
}
str2num::~str2num()
{
}
int main( ){
vector<int> widths = {10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
string S = "abcdefghijklmnopqrstuvwxyz";
str2num str2 = str2num();
vector<int> res = str2.numberOfLines(widths,S);
cout << res[0] << endl;
cout << res[1] << endl;
return 0;
}