アレイがC#で同期されているかどうかを確認します
配列が同期されているかどうかを確認するためのコードは次のとおりです-
例
using System;
public class Demo {
public static void Main() {
string[] products = new string[] { };
Console.WriteLine("One or more planets begin with 'E'? = {0}",
Array.Exists(products, ele => ele.StartsWith("E")));
Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize);
Console.WriteLine("Is the array read only? = " + products.IsReadOnly);
Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized);
}
} 出力
これにより、次の出力が生成されます-
One or more planets begin with 'E'? = False Is the array having fixed size? = True Is the array read only? = False Is the array synchronized? = False
例
別の例を見てみましょう-
using System;
public class Demo {
public static void Main() {
String[] strArr1 = new String[3] { "John", "Jacob", "Tim"};
String[] strArr2 = new String[3] { "Tom","Brad","Bradley"};
Console.WriteLine("First String array...");
foreach(string val in strArr1) {
Console.WriteLine(val);
}
Console.WriteLine("Is the 1st array having fixed size? = " + strArr1.IsFixedSize);
Console.WriteLine("Is the 1st array read only? = " + strArr1.IsReadOnly);
Console.WriteLine("Is the 1st array synchronized? = " + strArr1.IsSynchronized);
Console.WriteLine("\nSecond String array...");
foreach(string val in strArr2) {
Console.WriteLine(val);
}
Console.WriteLine("Is the 2nd array having fixed size? = " + strArr2.IsFixedSize);
Console.WriteLine("Is the 2nd array read only? = " + strArr2.IsReadOnly);
Console.WriteLine("Is the 2nd array synchronized? = " + strArr2.IsSynchronized);
Console.WriteLine("Are both the array objects equal? = "+strArr1.Equals(strArr2));
}
} 出力
これにより、次の出力が生成されます-
First String array... John Jacob Tim Is the 1st array having fixed size? = True Is the 1st array read only? = False Is the 1st array synchronized? = False Second String array... Tom Brad Bradley Is the 2nd array having fixed size? = True Is the 2nd array read only? = False Is the 2nd array synchronized? = False Are both the array objects equal? = False
-
アレイが回文であるかどうかをチェックするCプログラム
任意のサイズnの配列arr[]が与えられた場合、私たちのタスクは、配列が回文であるかどうかを確認することです。回文は、MADAM、NAMANなどのように、同じように前後に読み取ることができるシーケンスです。 したがって、配列が回文であるかどうかを確認するために、-のように配列を前後にトラバースできます。 例 Input: arr[] = {1, 0, 0, 1} Output: Array is palindrome Input: arr[] = {1, 2, 3, 4, 5} Output: Array is not palindrome 以下で使用されるアプローチは次のとおりです
-
アレイが回文であるかどうか、またはC++でSTLを使用していないかどうかを確認するプログラム
n個の整数の配列arr[n]が与えられた場合、タスクは配列が回文であるかどうかを見つけることです。 C++でSTLを使用して指定されたタスクを実行する必要があります。 C ++には、STL(標準テンプレートライブラリ)の機能があります。これは、データ構造と、スタック、キュー、リストなどのいくつかの機能を提供するために使用されるC ++テンプレートクラスのセットです。これらを使用するには、知識が必要です。テンプレートクラスの。 回文は、シーケンスの前または後ろから同じように読み取られるシーケンスです。回文の簡単な例としては、-MADAM、RACECARなどがあります。配列は、以下の例のような