很简单的一道题目,还是出现了一个小问题 !的运算级比%运算高,以后要小心...
#include <iostream>
using namespace std;
char num[101];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int top=-1;
int tag=0;//tag为偶数标示大写关闭
getchar();//去掉后面的换行
char input[10];
char temp[6];
while(n--)
{
gets(input);
if(strcmp(input,"Caps")==0){tag++;continue;}
strncpy(temp,input,5),temp[5]='/0';
if(strcmp(temp,"Shift")==0)
{
if(!(tag%2))num[++top]=input[6]-32;
else num[++top]=input[6];
}
else //单个字符
{
if(!(tag%2))num[++top]=input[0];
else num[++top]=input[0]-32;
}
}
for(int i=0;i<=top;i++)
cout<<num[i];
cout<<endl;
}
return 0;
}