C
C#14mo ago
Lilac

C# Cyclic Numbers Array Check Help

I'm doing a homework for my Programming Fundamentals subject, which requires me to enter N numbers into array A, tell if array A is cyclic? This is my progress so far:
c#
namespace _1_Dimensional_Array
{
internal class Program
{
static void Main(string[] args)
{
//formating
Console.OutputEncoding = System.Text.Encoding.Unicode;

//Request User Input
Console.Write("Enter the amount of elements of your array: "); //Determine the amount of numbers in this Array
//Process unwanted inputs
int how_much;
while (true)
{
if (int.TryParse(Console.ReadLine(), out how_much))
{
break;
}
else
{
Console.Write("Enter the amount of elements of your array: ");
}
}

// using Arrays
int[] numbers = new int[how_much]; //create an array based on the user request

// use loops

for (int i = 0; i < numbers.Length; i++)
{
//Store all answers
Console.Write($"Give me the {i} element of Array A: ");
int element_number = Convert.ToInt32(Console.ReadLine());
}



Console.ReadKey();
}
}
}
c#
namespace _1_Dimensional_Array
{
internal class Program
{
static void Main(string[] args)
{
//formating
Console.OutputEncoding = System.Text.Encoding.Unicode;

//Request User Input
Console.Write("Enter the amount of elements of your array: "); //Determine the amount of numbers in this Array
//Process unwanted inputs
int how_much;
while (true)
{
if (int.TryParse(Console.ReadLine(), out how_much))
{
break;
}
else
{
Console.Write("Enter the amount of elements of your array: ");
}
}

// using Arrays
int[] numbers = new int[how_much]; //create an array based on the user request

// use loops

for (int i = 0; i < numbers.Length; i++)
{
//Store all answers
Console.Write($"Give me the {i} element of Array A: ");
int element_number = Convert.ToInt32(Console.ReadLine());
}



Console.ReadKey();
}
}
}
7 Replies
FestivalDelGelato
what does cyclic mean?
Lilac
LilacOP14mo ago
So this is the definition from my lecturer: Question: Enter N numbers into array A, tell if array A is cyclic? * Definition: a periodic number is a number that repeats its value at regular intervals or cycles, For example: A = (1,3,2,1,3,2,1)         ---->    A is a non-cyclic number series A = (2,5,3,2,5,3,2,5,3)   ---->    A is a cyclic series I used a translation app for this definition
FestivalDelGelato
ok so how you plan to do this there are simpler ways and more complicated ways
Lilac
LilacOP14mo ago
can you show me a simple way? I've been struggling to understand how to do this based on the answer of chatgpt
FestivalDelGelato
what algorithms did you think of
Lilac
LilacOP14mo ago
I can't think of anything 🤷 I still have not learned about algorithm
FestivalDelGelato
😐 how do you recognize a sequence that repeats? like you you

Did you find this page helpful?