【测试自动化8】处理字符串 | |
描述: | 程序的规格说明要求:
请实现上述描述的程序. |
运行时间限制: | 10 Sec |
内存限制: | 200 MByte |
输入: | 无限制 |
输出: | N、M、对应字符串
|
样例输入: | #3012345 |
#include<iostream>
using namespace std;
int main()
{
char str[3000];
gets(str);
int len=strlen(str);
if(str[0]!='#')
cout<<"N"<<endl;
else
{
if(str[1]<48||str[1]>57)
cout<<"M"<<endl;
else
{
int num=str[1]-48;
for(int i=2;i<=2+num&&str[i]!='\0';i++)
cout<<str[i];
cout<<endl;
}
}
}