fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. const int MAX_LENGTH = 2000;
  6.  
  7. int main() {
  8. char a[MAX_LENGTH], b[MAX_LENGTH];
  9. cin >> a >> b;
  10. // cin.getline(a,MAX_LENGTH);
  11. // cin.getline(b,MAX_LENGTH);
  12. int lengthA = strlen(a);
  13. int lengthB = strlen(b);
  14. char *p ;
  15. if (strcmp(a, b) > 0) {
  16.  
  17. p = strstr(a, b);
  18. p = strstr(p + 1, b);
  19. cout << "DA";
  20. } else if (strcmp(a, b) < 0){
  21. p = strstr(b, a);
  22. // p = p - b;
  23. cout << "NU" << p - a;
  24. }
  25. cout << p <<"<--\n";
  26.  
  27. if (strcmp(a,b) == 0) {
  28. cout <<a << b;
  29. } else if (strcmp(a,b) != 0){
  30. while (p != 0) {
  31. cout << p - a;
  32. p = strstr(p + 1, b);
  33. }
  34. if (p == 0) {
  35. for (int i = 0; i < lengthA || i < lengthB ; ++i) {
  36. if (i > lengthA - 1 && i < lengthB ) {
  37. cout << b[i];
  38. } else if (i > lengthB - 1 && i < lengthA ) {
  39. cout << a[i];
  40. } else {
  41. cout << a[i] << b[i];
  42. // cout << a[i] << b[i]<< i <<";\n";
  43. }
  44.  
  45. }
  46. } else {
  47.  
  48. }
  49.  
  50. }
  51. //cout << "\n" << strcmp(a,b) << ".";
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5320KB
stdin
asdfg
asdfhh
stdout
NU-140724767875104