#include <iostream>
#include <string>
using namespace std;
int main()
{
char a[1001];
int b=0;
while(cin>>a)
{
int c=0,d;
b++;
for(int i=0;i<strlen(a);i++)
{
if(a[i]=='a')
c++;
}
d=strlen(a)-c;
cout<<"AB Circle #"<<b<<":"<<endl;
for(int i=0;i<strlen(a)-1;i++)
{
if(c>d)
{
if(i+c>strlen(a)-1)
cout<<i<<","<<i+d<<endl;
else
{cout<<i<<","<<i+d<<endl;
cout<<i<<","<<i+c<<endl;}
}
else if(c<d)
{
if(i+d>strlen(a)-1)
cout<<i<<","<<i+c<<endl;
else
{cout<<i<<","<<i+c<<endl;
cout<<i<<","<<i+d<<endl;}
}
else
{
cout<<i<<","<<i+c<<endl;
if(i+d>=strlen(a)-1)
break;
}
}
cout<<endl;
}
return 0;
}
因為每隔a的個數格和b的個數格便會滿足他的條件誰能糾正我的演算法