C 集合練習

2021-06-20 05:31:52 字數 998 閱讀 7399

namespace listdemo

#endregion

#region    把分揀奇偶數的程式用泛型實現。list

//random rand = new random();

//listl1=new list();

//listl2=new list();

//int i=0;

//while(i<10)

////foreach (var item in l1)

//  );

//foreach (var item in l2)

//#endregion

#region  從乙個整數的list中取出最大數(找最大值)。別用max方法

//listl3 = new list(new int );

//int max=0;

//foreach (var item in l3)

//  max );

#endregion

#region  把123轉換為:壹貳叄。dictionary

//string str = "1壹 2貳 3叄 4肆 5伍 6陸 7柒 8捌 9玖 0零";

//string parts = str.split(' ');

//dictionarydict = new dictionary();

//for (int i = 0; i < parts.length    ; i++)

////while (true)

////    else

//    

//    }

//}輸出統計結果

//foreach (keyvaluepairitem in dict1)

// ",item.key,item.value);

//}#endregion

#region

#endregion

console.readkey();}}

}

集合,集合的練習

set不支援 索引,切片,重複,連線,因為set是無序的 s print s 列表去重 li 1,2,3,1,2,3 print list set li s1 s2 print 並集 s1.union s2 並集 print 交集 s1.intersection s2 交集 求交集時,把s1的值更新...

集合的練習

案例 把分揀奇偶數的程式用泛型實現。int nums 奇數在左邊 偶數在右邊 listlist new list listodd new list 奇數 listeven new list 偶數 for int i 0 i list.count i else stringbuilder sb new...

set集合練習

public class test1 5,遍歷hashset for integer integer hs public class test2 4,遍歷hashset,列印每乙個字元 for character ch hs public class test3 分析 去除list集合中的重複元素 ...