很簡單的一道題目,還是出現了一個小問題 !的運算級比%運算高,以後要小心...
#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;
}