SHOW:
|
|
- or go back to the newest paste.
| 1 | - | //Write an expression that checks for given integer if its third digit (right-to-left) is 7. E. g. 1732 true. |
| 1 | + | //Write an expression that checks for given integer if its third digit (right-to-left) is 7. E. g. 1732 true. |
| 2 | - | using System; |
| 2 | + | using System; |
| 3 | - | |
| 3 | + | |
| 4 | - | class Program |
| 4 | + | class Program |
| 5 | - | { |
| 5 | + | {
|
| 6 | - | static void Main() |
| 6 | + | static void Main() |
| 7 | - | { |
| 7 | + | {
|
| 8 | - | int number = int.Parse(Console.ReadLine()) / 100; //if the number is 1732, number equals 17 |
| 8 | + | int number = Math.Abs(int.Parse(Console.ReadLine())) / 100; //if the number is 1732, number equals 17; we make the number with an absolute value in order t work for negative numbers |
| 9 | - | Console.WriteLine(number%10 == 7); |
| 9 | + | Console.WriteLine(number%10 == 7); |
| 10 | - | } |
| 10 | + | } |
| 11 | } |