More actions
imported>undinekr No edit summary |
(Repair batch-0002 pages from live compare) |
||
| Line 13: | Line 13: | ||
class Program | class Program | ||
{ | { | ||
static void Main(string | static void Main(string[] args) | ||
{ | { | ||
String text = System.Console.ReadLine(); | String text = System.Console.ReadLine(); | ||
| Line 19: | Line 19: | ||
{ | { | ||
bool isJollyJumpers = true; | bool isJollyJumpers = true; | ||
String | String[] textNums = text.Split(' '); | ||
int | int[] nums = new int[textNums.Length]; | ||
for (int i = 0; i < nums.Length; ++i) | for (int i = 0; i < nums.Length; ++i) | ||
{ | { | ||
nums | nums[i] = int.Parse(textNums[i]); | ||
} | } | ||
if (0 == nums | if (0 == nums[0]) | ||
{ | { | ||
return; | return; | ||
| Line 31: | Line 31: | ||
for (int i = 1; i < nums.Length - 1; ++i) | for (int i = 1; i < nums.Length - 1; ++i) | ||
{ | { | ||
if (nums | if (nums[0] <= Math.Abs(nums[i] - nums[i + 1])) | ||
{ | { | ||
isJollyJumpers = false; | isJollyJumpers = false; | ||
| Line 52: | Line 52: | ||
---- | ---- | ||
[[JollyJumpers]] | [[JollyJumpers]] | ||
Latest revision as of 00:16, 27 March 2026
JollyJumpers/조현태
- 이렇게 짜면 안됀다는걸 잘 보여주는 예.
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JollyJumpers
{
class Program
{
static void Main(string[] args)
{
String text = System.Console.ReadLine();
while (null != text && 0 != text.Length)
{
bool isJollyJumpers = true;
String[] textNums = text.Split(' ');
int[] nums = new int[textNums.Length];
for (int i = 0; i < nums.Length; ++i)
{
nums[i] = int.Parse(textNums[i]);
}
if (0 == nums[0])
{
return;
}
for (int i = 1; i < nums.Length - 1; ++i)
{
if (nums[0] <= Math.Abs(nums[i] - nums[i + 1]))
{
isJollyJumpers = false;
break;
}
}
if (isJollyJumpers)
{
System.Console.WriteLine("Jolly");
}
else
{
System.Console.WriteLine("Not jolly");
}
text = System.Console.ReadLine();
}
}
}
}