using System;
using System.Threading;
class Program
{
static void Main()
{
// Array to be used by the first thread
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
// Default string to be reversed
string input = "DefaultString"; // You can change this value
// Create and start threads
Thread t1 = new Thread(() => CalculateSquares(arr));
Thread t2 = new Thread(() => ReverseString(input));
t1.Start();
t2.Start();
// Wait for both threads to finish
t1.Join();
t2.Join();
}
// Method to calculate and print squares of array elements
static void CalculateSquares(int[] arr)
{
Console.WriteLine("Original Array: " + string.Join(", ", arr));
Console.Write("Squares of Array Elements: ");
foreach (int number in arr)
{
Console.Write(number * number + " ");
}
Console.WriteLine();
}
// Method to reverse a string
static void ReverseString(string str)
{
char[] charArray = str.ToCharArray();
Array.Reverse(charArray);
string reversed = new string(charArray);
Console.WriteLine($"Original String: {str}");
Console.WriteLine($"Reversed String: {reversed}");
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGhyZWFkaW5nOwoKY2xhc3MgUHJvZ3JhbQp7CiAgICBzdGF0aWMgdm9pZCBNYWluKCkKICAgIHsKICAgICAgICAvLyBBcnJheSB0byBiZSB1c2VkIGJ5IHRoZSBmaXJzdCB0aHJlYWQKICAgICAgICBpbnRbXSBhcnIgPSB7IDEsIDIsIDMsIDQsIDUsIDYsIDcsIDgsIDksIDEwIH07CgogICAgICAgIC8vIERlZmF1bHQgc3RyaW5nIHRvIGJlIHJldmVyc2VkCiAgICAgICAgc3RyaW5nIGlucHV0ID0gIkRlZmF1bHRTdHJpbmciOyAvLyBZb3UgY2FuIGNoYW5nZSB0aGlzIHZhbHVlCgogICAgICAgIC8vIENyZWF0ZSBhbmQgc3RhcnQgdGhyZWFkcwogICAgICAgIFRocmVhZCB0MSA9IG5ldyBUaHJlYWQoKCkgPT4gQ2FsY3VsYXRlU3F1YXJlcyhhcnIpKTsKICAgICAgICBUaHJlYWQgdDIgPSBuZXcgVGhyZWFkKCgpID0+IFJldmVyc2VTdHJpbmcoaW5wdXQpKTsKCiAgICAg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Original Array: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Squares of Array Elements: 1 4 9 16 25 36 49 64 81 100
Original String: DefaultString
Reversed String: gnirtStluafeD