Skip to content

Naruto and Sasuke are on a S- Rank mission. They got bored and thought of competing in a race against each other in a horizontal plane. They decided a common spot "C" at which both of them will try to reach. Whoever reaches first wins the race, both of them run at the same speed. Given initial positions of Naruto and Sasuke you need to tell whic…

Notifications You must be signed in to change notification settings

nitish4445/Race

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Race

Naruto and Sasuke are on a S- Rank mission. They got bored and thought of competing in a race against each other in a horizontal plane. They decided a common spot "C" at which both of them will try to reach. Whoever reaches first wins the race, both of them run at the same speed. Given initial positions of Naruto and Sasuke you need to tell which of them will win the race. If Naruto wins print "N" ( without the quotes ), if Sasuke wins print "S" ( without the quotes ). if both of them reach the common spot at the same time, print "D" (for draw, without the quotes ). Input

static char Race(int A,int B,int C){ int naruto = Math.abs(A - C); int sasuke = Math.abs(B - C); if(naruto<sasuke){

return 'N';

}if(naruto>sasuke){

return 'S' ;

}

else return 'D' ; }

About

Naruto and Sasuke are on a S- Rank mission. They got bored and thought of competing in a race against each other in a horizontal plane. They decided a common spot "C" at which both of them will try to reach. Whoever reaches first wins the race, both of them run at the same speed. Given initial positions of Naruto and Sasuke you need to tell whic…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published