convert

Need to convert python 3 to C++
A.'city' as a null terminated string.
B. C++ function bool isVowel(char c)

def scoreCity(city)
score = 10
for ei in City:
if isVowel(ei)
score +=12
elif ei in ['r','v']:
score +=13
elif ei in ['m']:
score *=10
else:
score +=11
return score
Last edited on
Not that I know python, I guess
1
2
3
4
5
6
7
8
9
10
int scoreCity( const char* city ) {
   int score = 10;
   for( ; *city != 0; city++ ) { // there are alternatives here
      if( isVowel( *city ) ) score += 12;
      else if( *city == 'r' || *city == 'v' ) score += 13;
      else if( *city == 'm' ) score *= 10;
      else score += 11;
   }
   return score;
}
Topic archived. No new replies allowed.