fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. #define T_SIZE 1001
  7.  
  8. char* string_merge(char *, char *);
  9.  
  10. int main()
  11. {
  12. int t;
  13. char S1[T_SIZE], S2[T_SIZE], *S;
  14. cin >> t;
  15. cin.getline(S1,T_SIZE);
  16. while(t)
  17. {
  18. cin.getline(S1,T_SIZE,' ');
  19. cin.getline(S2,T_SIZE);
  20. S=string_merge(S1,S2);
  21. cout << S << endl;
  22. delete[] S;
  23. t--;
  24. }
  25. return 0;
  26. }
  27.  
  28. char* string_merge(char *S1, char *S2)
  29. {
  30. int dl1=strlen(S1);
  31. int dl2=strlen(S2);
  32. int koniec=dl1;
  33. char wynik[T_SIZE];
  34. if(dl1>dl2)
  35. koniec=dl2;
  36. int j=1,k=0;
  37. for(int i=0;i<koniec;i++)
  38. {
  39. wynik[k]=S1[i];
  40. wynik[j]=S2[i];
  41. j=j+2;
  42. k=k+2;
  43. }
  44. for(int i=2*koniec;i<=(2*koniec)+2;i++)
  45. {
  46. wynik[i]='\0';
  47. }
  48. return wynik;
  49. }
  50.  
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
Standard output is empty