/*
题目要求把字符串BRGBBGRRGBBGBBBGRRGBGRG按RGB顺序排列,空间复杂度为O(1)
*/ #includeusing namespace std;int main(){ char a[]="BRGBBGRRGBBGBBBGRRGBGRG\0"; for(int i=0;i < strlen(a);i++) { if(a[i]=='R') { for(int j=0;j < i;j++) { if(a[j]!='R') { char temp = a[j]; a[j] = a[i]; a[i] = temp; break; } } } if(a[i]=='B') { for(int j=strlen(a)-1;j>i;j--) { if(a[j]!='B') { char temp = a[j]; a[j] = a[i]; a[i] = temp; i--; break; } } } } for(int i=0;i >signal;}