Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string stringGreaterValue(string s1, string s2) {
- return s1 > s2 ? s1 : s2;
- }
- char charGreaterValue(char c1, char c2) {
- return c1 > c2 ? c1 : c2;
- }
- int intGreaterValue(int n1, int n2) {
- return n1 > n2 ? n1 : n2;
- }
- int main() {
- string type;
- cin >> type;
- cin.ignore();
- string firstValue, secondValue;
- getline(cin, firstValue);
- getline(cin, secondValue);
- if (type == "int") {
- cout << intGreaterValue(stoi(firstValue), stoi(secondValue));
- }
- else if (type == "char") {
- cout << charGreaterValue(firstValue.at(0), secondValue.at(0));
- }
- else if (type == "string") {
- cout << stringGreaterValue(firstValue, secondValue);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement