Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Main.cs created with MonoDevelop
- // Jeffrey
- //
- // To change standard headers go to Edit->Preferences->Coding->Standard Headers
- //
- using System;
- using System.IO;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace JollyJumpers
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- try
- {
- StreamReader inFile = new StreamReader("input.in");
- StreamWriter outFile = new StreamWriter("output.out");
- MatchCollection matches = Regex.Matches(inFile.ReadLine(), @"\d+");
- int quantity;
- int[] numbers;
- int[] results;
- while(!inFile.EndOfStream)
- {
- quantity = Convert.ToInt32(matches[0].ToString());
- numbers = new int[quantity];
- results = new int[quantity-1];
- bool flag = true;
- for(int i=0; i < quantity; i++)
- numbers[i] = Convert.ToInt32(matches[i+1].ToString());
- for(int i=0; i < quantity-1; i++)
- results[i] = Math.Abs(numbers[i] - numbers[i+1]);
- for(int i=0; i < quantity-2; i++)
- {
- if(Math.Abs(results[i] - results[i+1]) != 1)
- {
- flag = false;
- break;
- }
- }
- if(flag)
- outFile.WriteLine("Jolly");
- else
- outFile.WriteLine("Not Jolly");
- matches = Regex.Matches(inFile.ReadLine(), @"\d+");
- numbers = null;
- results = null;
- }
- Console.Write("Finishing the Program");
- Console.Read();
- inFile.Close();
- outFile.Close();
- }
- catch(System.IO.FileNotFoundException)
- {
- Console.WriteLine("File does not exist");
- Console.Read();
- }
- catch
- {
- Console.WriteLine("Something Unexpected happened");
- Console.Read();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement