第五周作業

2021-09-13 20:46:51 字數 2852 閱讀 1497

1、由使用者輸入銀行的英文簡稱,使用if ... else if 語句判斷並輸出銀行的中文全稱。

要點:分別使用if ... else if 語句和switch語句

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace demo_ifelse}}

2、由使用者輸入銀行的英文簡稱,使用switch(...)語句判斷並輸出銀行的中文全稱。

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace demo_ifelse}}

3、設計乙個程式計算1~100之間的奇數和、偶數和。

4、設計乙個程式列印一張九九選乘法表。

5、設計一程式,演示一維陣列、二維數的定義、初始化、陣列元素的賦值與取數。

要點:定長多維陣列、非定長多維陣列的定義、初始化、陣列行數和列數的獲取。array.length與array.getlength(0)、array.getlength(1)的含義及用法。

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace demo_array2

; int[,] arr1 = new int[2,3];//定長二維陣列

int arr2 = new int[2];//非定長二維陣列

arr2[0] = new int[3];

arr2[1] = new int[8];

int[,] a = new int[2,3] ,};

for(int i=0;i6、設計乙個程式,演示arraylist的用法(定義、排序、增加、插入、刪除、查詢等)。

要點:需要引用下面的命名空間:

using system.collections;

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

using system.collections;

namespace demo_arraylist

; arraylist list = new arraylist(a);

console.writeline("陣列的原始值:");

for(int i=0;i7、設計乙個程式,演示hashtable的用法(contains,containskey,containsvalue的用法)

要點:如何進行遍歷?

hashtable

hashtable

= new

hashtable

(); //

建立hashtable物件

hashtable.add

("id", "bh0001"); //

向hashtable

中新增元素

hashtable.add

("name", "tm");

hashtable.add

("***", "

男");

console.writeline

("\t

鍵\t

值");

foreach

(dictionaryentry

dicentry

in hashtable)

舉個例子:

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

using system.collections;

namespace demo_hashtable

",srvinfo["srvip"]);

console.writeline("dbname=",srvinfo["dbname"]);

console.writeline("username=", srvinfo["username"]);

console.writeline("userpwd=", srvinfo["userpwd"]);

console.writeline();//輸出乙個換行

if (srvinfo.contains("dbname")) //等價於srvinfo.containskey("dbname")

if (srvinfo.containsvalue("jfglxt"))

system.console.readkey();}}

}

第五周作業

includeusing namespace std class student 用引數的初始化表對資料成員初始化。void max student arr void display private int num int score void student display void studen...

第五周作業

5求自然對數 include using namespace std int main cout e 6求圓周率 include include using namespace std int main cout pi約等於 7 include using namespace std int mai...

第五周作業

注意 總時間限制 1000ms 記憶體限制 65536kb 描述寫乙個mystring 類,使得下面程式的輸出結果是 1.abcd efgh abcd 2.abcd 3.4.abcd efgh 5.efgh 6.c 7.abcd 8.ijal 9.ijal mnop 10.qrst abcd 11....