text: I've been working on this problem for quite a while. Everytime I try to change the code to make it work, I run into more and more problems. Anyway this is the problem:
  ****** *****
  Here's the code I'm using. If someone knows a good or better way to approach the problem just say the word.
  Thanks!!Thanks!!Code:#include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; int main() { int n, n1=1, n2=1; string bString; string combString; char khar; char zhar; /* ifstream fin("beads.in",ios::in); ofstream fout("beads.out",ios::out); if(!fin) { cerr << "File could not be opened"; exit(1); } if(!fout) { cerr << "File could not be opened"; exit(1); } */ cin >> n >> bString; vector<int> n1array(n); vector<int> n2array(n); vector<int> n3array(n); for (int s=0; s<n; s++) { n1array[s]=0; n2array[s]=0; } combString=bString+bString; for (int k=0;k<n;k++) { for(int i=k; combString[i]==combString[i-1] || combString[i]==khar; i--)// loop backward { if (combString[i-1]=='w' && combString[i] !='w') { khar=combString[i]; cout << combString[i] <<endl; } if (combString[i-1]!='w' && combString[i]=='w') { n1++; n1array[k]=n1; } n1++; n1array[k]=n1; } for(int j=k+1; combString[j]==combString[j+1] || combString[j]==zhar; j++)//loop forward { if (combString[j+1]=='w' && combString[j] !='w') { zhar=combString[j]; cout << combString[j] << endl; } if (combString[j+1] !='w' && combString[j]=='w') { n2++; n2array[k]=n2; } n2++; n2array[k]=n2; } } for (int e=0; e<n; e++)//fill empty ones { if (n1array[e]==0) n1array[e]=1; if (n2array[e]==0) n2array[e]=1; } for (int l=0; l<n; l++)//combine both arrays { n3array[l]= n1array[l]+n2array[l]; } int temp=n3array[0]; for (int m=0; m<n; m++)//calculate highest value { if (n3array[m]>temp) temp=n3array[m]; } if (temp>n) temp=n; cout << temp << "\n"; int we; cin >>we; return 0; }