Skip to content

Instantly share code, notes, and snippets.

@dcrystalj
Created March 2, 2015 19:34
Show Gist options
  • Save dcrystalj/abc4ab09a5c04f91b389 to your computer and use it in GitHub Desktop.
Save dcrystalj/abc4ab09a5c04f91b389 to your computer and use it in GitHub Desktop.
Brdcpp
#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