HDOJ2265(Encoding The Diary)无聊题
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
const int MAX_LEN = 205;
int main()
{
string str;
char cc[MAX_LEN];
bool visited[MAX_LEN];
int i, j;
while(cin.getline(cc, 203,'\n'))
{
str = "";
for(i = 0; i < strlen(cc); i++)
{
if(cc[i] != ' ')
str += cc[i]; //去空格
visited[i] = false;
}
visited[str.length()] = false;
for(i = 3; i <= str.length(); i += 3)
{
cout<<str[i - 1];
visited[i] = true;
}
for(i = 2; i <= str.length(); i += 2)
if(!visited[i])
{
cout<<str[i - 1];
visited[i] = true;
}
for(i = 1; i <= str.length(); i++)
if(!visited[i])
cout<<str[i - 1];
cout<<endl;
}
return 0;
}
#include <string>
#include <cstring>
using namespace std;
const int MAX_LEN = 205;
int main()
{
string str;
char cc[MAX_LEN];
bool visited[MAX_LEN];
int i, j;
while(cin.getline(cc, 203,'\n'))
{
str = "";
for(i = 0; i < strlen(cc); i++)
{
if(cc[i] != ' ')
str += cc[i]; //去空格
visited[i] = false;
}
visited[str.length()] = false;
for(i = 3; i <= str.length(); i += 3)
{
cout<<str[i - 1];
visited[i] = true;
}
for(i = 2; i <= str.length(); i += 2)
if(!visited[i])
{
cout<<str[i - 1];
visited[i] = true;
}
for(i = 1; i <= str.length(); i++)
if(!visited[i])
cout<<str[i - 1];
cout<<endl;
}
return 0;
}