File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 3
3
public class Nsteps {
4
4
public static long CoordsToNumber ( long x , long y ) {
5
5
if ( y != ( x - 2 ) && y != x ) {
6
- return - 1 ;
6
+ throw new ArgumentOutOfRangeException ( ) ;
7
7
}
8
8
if ( x % 2 == 0 ) {
9
9
return x + y ;
@@ -16,11 +16,11 @@ public static void Main() {
16
16
int lines = Convert . ToInt32 ( Console . ReadLine ( ) ) ;
17
17
while ( lines -- > 0 ) {
18
18
string [ ] tuple = Console . ReadLine ( ) . Split ( ' ' ) ;
19
- long number = CoordsToNumber ( Convert . ToInt64 ( tuple [ 0 ] ) , Convert . ToInt64 ( tuple [ 1 ] ) ) ;
20
- if ( number < 0 ) {
21
- Console . WriteLine ( "No Number" ) ;
22
- } else {
19
+ try {
20
+ long number = CoordsToNumber ( Convert . ToInt64 ( tuple [ 0 ] ) , Convert . ToInt64 ( tuple [ 1 ] ) ) ;
23
21
Console . WriteLine ( number ) ;
22
+ } catch ( ArgumentOutOfRangeException ) {
23
+ Console . WriteLine ( "No Number" ) ;
24
24
}
25
25
}
26
26
}
You can’t perform that action at this time.
0 commit comments