What did i do wrong i fail 1 test and when i try separated it outputs 672 .Why? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

What did i do wrong i fail 1 test and when i try separated it outputs 672 .Why?

2D Map You're given a representation of a 5x5 2D map, and if you can only move left, right, up, or down, determine how many moves you would have to make to get between two points on the map. Task: Determine the total number of moves that are needed between two points on a map. The points that you move between are marked with a P and the spaces in between are marked with X. Input Format: A string that represents the 2D space starting at the top left. Each level from top to bottom is separated by a comma. Output Format: An integer that represents the total number of moves that you had to make. Sample Input: XPXXX,XXXXX,XXXXX,XXXPX,XXXXX Sample Output: 5 https://code.sololearn.com/cwwmc0kPMv7a/?ref=app

9th Oct 2022, 10:41 AM
Costy Game
Costy Game - avatar
1 Resposta
+ 2
std::string::size function return size_t type, you try compare this with the x that is int type. size_t is unsigned long long int (unsigned int of 64 bits). The solutions: 1. change the type of x from int to size_t or 2. cast the return value of std::string::size to int. The 1st solution recommend
5th Nov 2022, 12:59 PM
Giannis
Giannis - avatar