/*******************
以前回答过了。再贴一遍
*******************/
#include<iostream>
#include<string>
//取得
字符串字符个数,不限中英文
unsigned int GetStringCount(const std::string &s)
{
short ch;
unsigned cnt = s.size();
for(size_t i=0; i<s.size(); ++i)
{
ch = s.at(i);
if(ch&0x1000) ++i,--cnt;
}
return cnt;
}
//取得以0为起始索引的指定位置字符
std::string GetString(std::string &s, size_t index)
{
short ch;
std::string res;
unsigned cnt = index;
for(size_t i=0; i<s.size() && i<cnt; ++i)
{
ch = s.at(i);
if(ch&0x1000) ++i,++cnt;
}
ch = s.at(i);
if(ch&0x1000) res=s.substr(i,2);
else res=s.substr(i,1);
return res;
}
//取字符串中的整型数,支持负数。string输入,vector输出
void get_int(const std::string& s, std::vector<int>& vi)
{
std::string::size_type size = s.size();
int element = 0;
bool now_digit = false;
bool negative = false;
for(std::string::size_type i=0; i<size; ++i)
{
if(s.at(i)<='9' && s.at(i)>='0')
{
now_digit = true;
element = element*10 + s.at(i)-'0';
}
else
{
if(s.at(i) == '-') negative = true;
else
{
if(now_digit)
{
if(negative) element = -element;
vi.push_back(element);
element = 0;
now_digit = false;
negative = false;
}
}
}
}
if(now_digit)
{
if(negative) element = -element;
vi.push_back(element);
}
}
int main()
{
std::string s;
std::cin>>s;
std::cout<<GetStringCount(s)<<std::endl;
std::cout<<GetString(s,2)<<std::endl;
std::vector<int> vi;
get_int(s, vi);
std::vector<int>::iterator it = vi.begin();
for(; it!=vi.end(); ++it) std::cout<<*it<<std::endl;
return EXIT_SUCCESS;
}