whats wrong with my code ?

#include <iostream>
#include <string>
using namespace std;

int main()
{
string entline = "";
int i = 0, n = 0, x = 0, linelen = 0, counter = 0, filler = 0;


cout << "Please enter a DNA sequence.";
getline( cin, entline );
linelen = entline.length();

cout << "Enter the number of consecutive t's in a sequence required to count as an occurance.";
cin >> n;

for( i = 0; i < linelen; i++)
{
if(entline[i] = 't')
{
for( x = 0; x != n; x++)
{
if(entline[x] = 't')
{
counter++;

}
}
}
}

cout << "There are " << counter << " occurances of " << n << " consecutive t's in the sequence." << endl;

cin >> filler;
return 0;
}
Last edited on
What makes you think there's something wrong with it?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <string>

using namespace std;

int main(){
	string entline="";
	int i=0, n=0, x=0, linelen=0, counter=0, filler=0;


	cout<<"Please enter a DNA sequence.";
	getline(cin, entline);
	linelen=entline.length();

	cout<<"Enter the number of consecutive t's in a sequence"
		<<"required to count as an occurance."<<endl;
	cin >> n;

	for(i=0; i<linelen; i++)
		if(entline[i]='t')
			for(x=0; x!=n; x++)
				if(entline[x]='t')
					counter++;

	cout<<"There are "<<counter<<" occurances of "<<n
		<<" consecutive t's in the sequence."<<endl;

	cin >> filler;
	return 0;
}


Made it readable. What's the problem?
Topic archived. No new replies allowed.