반응형
https://www.hackerrank.com/challenges/c-tutorial-strings/problem
#include <iostream>
#include <string>
using namespace std;
void SwapZeroLoc(char* str1,char* str2);
int main() {
// Complete the program
string f_str,s_str;
cin>>f_str;
cin.ignore();
getline(cin,s_str);
cout<<f_str.size()<<' '<<s_str.size()<<endl;
cout<<f_str+s_str<<endl;
SwapZeroLoc(&f_str[0],&s_str[0]);
cout<<f_str<<' '<<s_str;
return 0;
}
void SwapZeroLoc(char* str1,char* str2)
{
char tmp;
tmp=*str1;
*str1=*str2;
*str2=tmp;
}
반응형
'C++' 카테고리의 다른 글
[HackerRank] Box it! - easy (0) | 2019.10.23 |
---|---|
[HackerRank] Classes and Objects - Easy (0) | 2019.10.16 |
[HackerRank] StringStream - Easy (0) | 2019.10.14 |
[HackerRank]Attribute Parser - Medium (0) | 2019.10.14 |
[HackerRank] Variable Sized Arrays - Easy (0) | 2019.10.13 |
댓글