Created
March 2, 2015 19:34
-
-
Save dcrystalj/abc4ab09a5c04f91b389 to your computer and use it in GitHub Desktop.
Brdcpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string.h> | |
#include <algorithm> | |
#include <stdio.h> | |
using namespace std; | |
int main() | |
{ | |
char a [7]; | |
char b [7]; | |
char d; | |
char* max; | |
cin >> a; | |
cin >> b; | |
char* blen = b+strlen(b); | |
int changed = 1; | |
for (int i = 0; i < strlen(a); ++i) | |
{ | |
if (changed) | |
max = max_element(b, blen); | |
if (max[0] > a[i]) | |
{ | |
a[i] = max[0]; | |
max[0] = '0'; | |
changed = 1; | |
} | |
else changed = 0; | |
} | |
cout << a; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment