/* 获取int 入参类型的位数 */
int getIntLenth(int n)
{
int i = 0;
if ( 0 == n ) // 特殊入参的处理
{
return 1;
}
while ( 0!= n)
{
n = n/10 ;
i++;
}
return i;
}
/*将数字转化为字符(串)*/
//单个字符
char sz =5 +'0';
//字符串
int iToBeChange;
char aszbuffer[128];
memset(aszbuffer,'\0',sizeof(aszbuffer));
itoa(aszbuffer,iToBeChange,10);
/*
因为有^,所以结果可能很大~要进行取mod。but!溢出的话,相同的数溢出后仍然相等,所以不取mod其实也行
方法:
把变量代入一个值……然后按表达式计算进行比较
add_sub= {multiplication..} + || -
multiplication= {indexOP..} *
indexOP= {brackets_number..} ^
brackets_number= {(add_sub) || number}
*/
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
/*函数声明*/
int add_sub(); // '+' | '-'
int multiplication(); // '*'
int indexOP(); // '^'
int brackets_number(); // '()' | 'number'
int test_number[5]={-2,-1,0,1,2};//选择题,带值发
string ch,s,ss="";
int a,count,len,st[5],num[5],n;
void readin()
{
ch="";
getline(cin,ch);
len = ch.size();
s.erase();
for (int i=0;i<len;++i)
{
if (ch[i]!=' ')
{
s+=ch[i];
}
}
}
void del_space(char *pstr)
{
unsigned long ulLen =(unsigned long)strlen(pstr);
for (int i=0;i<ulLen;++i)
{
if (ch[i]!=' ')
{
s+=ch[i];
}
}
}
int equal(char *input,char *choose[],int choiceNum ,char*out)
{
if(NULL==input ||NULL==choose||NULL==out)
{
return 0;
}
return 1;
}
int main()
{
freopen("equal.in","r",stdin);
freopen("equal.out","w",stdout);
readin();
for (int i=0;i<5;++i)
{
a=test_number[i];
count=0;
st[i]=add_sub();
}
scanf("%d\n",&n);
for (int i=1;i<=n;++i)
{
readin();
for (int j=0;j<5;++j)
{
a=test_number[j];
count=0;
num[j]=add_sub();
}
int flag=1;
for (int j=0;j<5;++j)
{
if (st[j] != num[j])
{
flag=0;
break;
}
}
if (flag == 1)
{
printf("%c",(char) i+'A' -1);
}
}
return 0;
}
int add_sub()
{
int t1,t2;
t1=multiplication();
while (s[count] == '+' || s[count] == '-')
{
char c=s[count++];
t2=multiplication();
if (c=='+')
{
t1+=t2;
}
else
{
t1-=t2;
}
}
return t1;
}
int multiplication()
{
int t1,t2;
t1=indexOP();
while ( s[count] == '*')
{
++count;
t2=indexOP();
t1*=t2;
}
return t1;
}
int indexOP()
{
int t1,t2,t3;
t1=brackets_number();
while (s[count] == '^')
{
++count;
t2=brackets_number();
t3=t1;
for (int i=1;i<=t2-1;++i)
{
t1*=t3;
}
}
return t1;
}
int brackets_number()
{
int t1;
if (s[count] == '(')
{
++count;
t1=add_sub();
++count;
}else
if (s[count] == 'a' )
{
t1=a;
++count;
}
else
{
t1=0;
while ( isdigit(s[count]) )
{
t1=t1*10+s[count++]-'0';
}
}
return t1;
}
#include<stdio.h>
bool process(char *a,int end,int length);
int main(void)
{
char first[27];
int begin,end,length;
scanf("%d%d%d",&begin,&end,&length);
//吸收多余空格
getchar();
for(int i=0;i<length;i++)
scanf("%c",&first[i]);
first[length]='\0';
for(i=1;process(first,end,length) && i<=5;i++)
printf("%s\n",first);
return 0;
}
//下面这个函数用来求比传递过来的jam数大一的数
bool process(char *a,int end,int length)
{
bool sth=false;
char *p=a+length-1;
char max='a'+end-1;
for(;;p--,max--)
{
if(*p<max)
{
*p=*p+1;
for(int i=1;*(p+i);i++)
*(p+i)=*p+i;
sth=true;
break;
}
if(p==a)
break;
}
return sth;
}