按字节截取字符串_#include


#include<iostream>
#include<string>
using namespace std;
bool isnums(char a)
{
if((a>='A'&&a<='Z')||(a>='a'&&a<='z'))
return true;
return false;
}
int main()
{
string str;
int n;
while(cin>>str>>n)
{
if(isnums(str[n-1])==true||(isnums(str[n-1])==false&&isnums(str[n-2])==false))
cout<<str.substr(0,n)<<endl;
else if(isnums(str[n-1])==false&&isnums(str[n-2])==true)
cout<<str.substr(0,n-1)<<endl;
}
}