配列が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);
}
} 出力
これにより、次のコードが生成されます-
One or more planets begin with 'E'? = False Is the array having fixed size? = True Is the array read only? = False
例
別の例を見てみましょう-
using System;
public class Demo {
public static void Main(){
string[] products = { "Mobiles", "Laptop", "Watches", "Books" };
Console.WriteLine("Products list...");
foreach(string s in products){
Console.WriteLine(s);
}
Console.WriteLine("\nOne or more products begin with the letter 'C'? = {0}",
Array.Exists(products, ele => ele.StartsWith("C")));
Console.WriteLine("One or more planets begin with 'D'? = {0}",
Array.Exists(products, ele => ele.StartsWith("D")));
Console.WriteLine("One or more products begin with the letter 'T'? = {0}",
Array.Exists(products, ele => ele.StartsWith("T")));
Console.WriteLine("One or more planets begin with 'E'? = {0}",
Array.Exists(products, ele => ele.StartsWith("E")));
Console.WriteLine("Is the array read only? = " + products.IsReadOnly);
}
} 出力
これにより、次のコードが生成されます-
Products list... Mobiles Laptop Watches Books One or more products begin with the letter 'C'? = False One or more planets begin with 'D'? = False One or more products begin with the letter 'T'? = False One or more planets begin with 'E'? = False Is the array read only? = False
-
Cの配列内の範囲の積
配列、L、R、Pを入力として指定し、タスクは、モジュロの下の積を出力としてLとRの間の範囲を見つけ、それを表示することです。 図に示されているように、要素の配列と、2としての左の値であるLと2としての右の値であるRがあります。ここで、プログラムはそれらの間の範囲の積を見つける必要があります。 例 Input-: A[] = { 1, 2, 3, 4, 5, 6 } P = 29 L = 2 R = 6 Output-: 24 Input-: A[] = {1, 2, 3, 4, 5, 6}, L =
-
アレイが回文であるかどうか、またはC++でSTLを使用していないかどうかを確認するプログラム
n個の整数の配列arr[n]が与えられた場合、タスクは配列が回文であるかどうかを見つけることです。 C++でSTLを使用して指定されたタスクを実行する必要があります。 C ++には、STL(標準テンプレートライブラリ)の機能があります。これは、データ構造と、スタック、キュー、リストなどのいくつかの機能を提供するために使用されるC ++テンプレートクラスのセットです。これらを使用するには、知識が必要です。テンプレートクラスの。 回文は、シーケンスの前または後ろから同じように読み取られるシーケンスです。回文の簡単な例としては、-MADAM、RACECARなどがあります。配列は、以下の例のような