Question about if...

Hello I need to finf if line has more a than b letters.
1
2
3
4
5
6
7
8
9
string b = "bB";
	string a = "aA";
	for(int i=0; i<E.length(); i++){
		if(a.find(E[i]) > b.find(E[i])){
			cout << " line with a < endl;" << endl;
		}else{
			cout << "line with b" << endl;
		}
	}
"more" implies counting, but you don't count anything.
Study more carefully what the string::find actually returns.

http://www.cplusplus.com/reference/algorithm/count/
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bool ArDaugiau(string E){
	string b = "bB";
	string a = "aA";
	int balskiek = 0;
	int priekiek = 0;
	for(int i=0; i<E.length(); i++){
		if(a.find(E[i]) > b.find(E[i])){
			balkiek++
		}else{
			priekiek++;
		}
	}
		if(balskiek > priekiek){
			return true;
		}
	}
	return false;
}

correct?
Last edited on
Please, explain what happens on line 7, and when does line 10 execute.

For example, who wins if E="cdefg"?
on line 7 i try to check if if a > b
my line E = abcdefghaaaaa
Last edited on
Topic archived. No new replies allowed.