fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6. #define T_SIZE 1001
  7.  
  8. char* string_merge(char *, char *);
  9.  
  10. int main(){
  11. int t,n;
  12. char S1[T_SIZE], S2[T_SIZE], *S;
  13. cin >> t; /* wczytaj liczbę testów */
  14. cin.getline(S1,T_SIZE); while(t){
  15. cin.getline(S1,T_SIZE,' ');
  16. cin.getline(S2,T_SIZE);
  17. S=string_merge(S1,S2);
  18. cout << S << endl;
  19. delete[] S;
  20. t--;
  21. }
  22. return 0;
  23. }
  24. char* string_merge(char *s1, char *s2)
  25. {
  26. int a = strlen(s1);
  27. int b = strlen(s2);
  28. int z=0,f=0;
  29.  
  30. if (a>=b)
  31. z = b;
  32. else
  33. z = a;
  34. char *tab = new char [z*2];
  35.  
  36.  
  37.  
  38. for(int i =0; i<z; i++)
  39. {
  40. tab[f] = s1[i];
  41. f++;
  42. tab[f] = s2[i];
  43. f++;
  44. }
  45. tab[f] = '\0';
  46. return tab;
  47. delete [] tab;
  48.  
  49. }
Success #stdin #stdout 0s 3472KB
stdin
4
a bb
abs sfd
ewr w
wqeqweqweq eqweqwe
stdout
ab
asbfsd
ew
weqqewqewqewqe