A. Angry Students(按要求做)
题意 打雪仗 :
简单总结就是找最后一个A 后面有多少个P
代码实现
#include <cstdio>
#include <stdio.h>
#include <iostream>
char s[1005];
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d %s", &n, s+1);
bool flag;
int cnt=-1;
do
{
flag=0; cnt++;
for (int i=n-1; i>=1; i--)
if (s[i]=='A'&&s[i+1]=='P')
{ s[i+1]='A';
flag=1;
}
} while (flag);
printf("%d\n", cnt);
}
return 0;
}