Witam. Mam pewien problem z zadaniem StringMerge ze spoja. Niby jak odpalam program i podaje dane wynik jest dobry ale sedzia tego nie akceptuje. Oto kod progarmu. Prosze o pomoc i z gory dziekuje. :) Oto kod.
#include <iostream>
#include <cstring>
using namespace std;
#define T_SIZE 1001
char* string_merge(char* s1, char* s2)
{
int size(0);
if(strlen(s1) < strlen(s2))
size = 2strlen(s1);
else if(strlen(s1) > strlen(s2))
size = 2strlen(s2);
else
size = strlen(s1) + strlen(s2);
char* str = new char[size+1];
for(int i=0,j=0; i<size; i+=2, j++) {
str[i] = s1[j];
str[i+1] = s2[j];
}
return str;
}
int main()
{
ios_base::sync_with_stdio(0);
int t;
char S1[T_SIZE], S2[T_SIZE], *S;
cin >> t;
cin.getline(S1,T_SIZE);
while(t--){
cin.getline(S1,T_SIZE,' ');
cin.getline(S2,T_SIZE);
S=string_merge(S1,S2);
cout << S << endl;
delete[] S;
}
system("pause");
return 0;
}