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
|
#include <cctype>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
class WeightReceiver {
public:
double Weight;
void ReceiveWeight()
{
std::string line;
std::stringstream sstream;
std::cout << "Enter the weight in kilograms: " << std::flush;
std::getline(std::cin, line);
sstream.str(line);
sstream >> Weight;
Weight *= 2.2;
}
};
class WeightEmitter {
private:
std::vector <char> Data;
public:
WeightEmitter()
{
Data = {
90, 108, 32, 121, 114, 112, 103, 104, 101, 114, 101,
32, 118, 102, 32, 110, 97, 32, 118, 113, 118, 98, 103,
32, 118, 115, 32, 117, 114, 32, 103, 117, 118, 97, 120,
102, 32, 86, 32, 106, 101, 98, 103, 114, 32, 103, 117,
118, 102, 32, 111, 108, 32, 122, 108, 102, 114, 121,
115, 46, 32, 78, 112, 103, 104, 110, 121, 121, 108, 44,
32, 86, 32, 112, 117, 114, 110, 103, 114, 113, 32, 110,
97, 113, 32, 112, 98, 99, 118, 114, 113, 32, 110, 32,
102, 98, 121, 104, 103, 118, 98, 97, 32, 98, 115, 115,
32, 98, 115, 32, 103, 117, 114, 32, 86, 97, 103, 114,
101, 97, 114, 103, 46, 32, 85, 98, 99, 114, 115, 104,
121, 121, 108, 32, 103, 117, 110, 103, 32, 122, 104,
112, 117, 32, 118, 102, 32, 98, 111, 105, 118, 98, 104,
102, 44, 32, 103, 117, 98, 104, 116, 117, 44, 32, 102,
118, 97, 112, 114, 32, 106, 114, 32, 99, 101, 98, 111,
110, 111, 121, 108, 32, 117, 110, 105, 114, 97, 39, 103,
32, 113, 98, 97, 114, 32, 112, 121, 110, 102, 102, 114,
102, 44, 32, 102, 103, 101, 118, 97, 116, 102, 103, 101,
114, 110, 122, 102, 32, 98, 101, 32, 105, 114, 112, 103,
98, 101, 102, 32, 108, 114, 103, 46, 32, 86, 115, 32,
110, 97, 108, 98, 97, 114, 32, 114, 121, 102, 114, 32,
18, 102, 32, 101, 114, 110, 113, 118, 97, 116, 32, 103,
117, 118, 102, 44, 32, 99, 121, 114, 110, 102, 114, 32,
113, 98, 97, 39, 103, 32, 116, 118, 105, 114, 32, 103,
117, 114, 32, 116, 110, 122, 114, 32, 110, 106, 110,
108, 46, 10, 99, 46, 102, 46, 32, 103, 117, 118, 102,
32, 102, 98, 121, 104, 103, 118, 98, 97, 32, 112, 110,
122, 114, 32, 115, 101, 98, 122, 32, 117, 103, 103, 99,
58, 47, 47, 112, 99, 121, 104, 102, 99, 121, 104, 102,
46, 112, 98, 122, 47, 115, 98, 101, 104, 122, 47, 121,
98, 104, 97, 116, 114, 47, 55, 51, 48, 50, 55, 47, 10,
66, 117, 44, 32, 110, 97, 113, 44, 32, 108, 98, 104,
101, 32, 106, 114, 118, 116, 117, 103, 32, 118, 102, 32
};
}
void EmitWeight(double weight)
{
for (auto it = Data.begin(); it < Data.end(); ++it) {
int c = tolower(*it);
if (isalpha(c)) {
if (c - 'a' < 13)
*it += 13;
else
*it -= 13;
}
std::cout << *it;
}
std::cout << weight << " lbs." << std::endl;
}
};
int main()
{
WeightReceiver recv;
WeightEmitter emit;
recv.ReceiveWeight();
emit.EmitWeight(recv.Weight);
return 0;
}
|