#include <iostream>
#include <queue>
#include <string>
using namespace std;
class Solution {
public:
string trans(string s) {
int n = s.length();
string r = "";
for (int i = 0; i < n; i++) {
if (s[i] == ' ') {
r += "%20";
}else {
r += s[i];
}
}
return r;
}
};
int main() {
string s = "We are happy.";
Solution test;
cout << test.trans(s) << endl;
}
#include <iostream>
#include <queue>
#include <string>
using namespace std;
class Solution {
public:
string trans(string s) {
int n = s.length();
string r = "";
for (char c : s) {
if (c == ' ') {
r += "%20";
}else {
r += c;
}
}
return r;
}
};
int main() {
string s = "We are happy.";
Solution test;
cout << test.trans(s) << endl;
}