The list of the most common linear structures we have in algorithmic design is just a few:1. Arrays:The array should be one of my most common. His storage address is continuous, that is, when we open an array, we will assign him a continuous address. Since his address is continuous, it is very fast to find the element when we know he is subscript.2. Linked list:The position of the elements in the list is not fixed, and each node in the list has a head pointer and a tail pointer, which connects t
==null){printf ("The list is null\n");return-1;}Chainlist_all (head);return 0;}int menu (){printf ("********************\n");printf ("1.add a contact\n");printf ("2.find a contact\n");printf ("3.delete a contact\n");printf ("4.insert a contact\n");printf ("5.show a contact\n");printf ("0.quit");printf ("\ n");printf ("********************\n");}int main (){int opt = 0;Chainlisttype *head=null;Do{printf ("\ n");printf ("Please select option!\n");menu ();scanf ("%d", opt);printf ("You select for%d\
bounce loop, continue is the end of the current loop into the next loop.7, List (array)stus=[' Saki ', ' Yuri ', ' MIMO ' #定义数组Subscript (angle, index, number) 0 1 2Stus[0] means Saki stus[1] represents Yuri, subscript starting from 08, list additions and deletions to check# Add stus.append (' Sami ') #在列表末尾增加一个元素 stus.insert (0, ' Kumi ')#在指定位置添加一个元素# Delete Stus.pop (2)#删除指定位置的元素 del stus[3]#删除指定位置的元素 stus.remove (' Saki ')#删除指定的元素 stus.clear ()#清空整个list# Modifystus[2]= ' Miumiu '# Check Prin
Title: Merging two sorted listsTitle Description: Input two monotonically increasing list, output two linked list of the linked list, of course, we need to synthesize the linked list to meet the monotone non-reduction rules.The idea that the problem is not difficult to feel, that is, under the discussion of the situation, there are two ways of circulation recursion1 Public classSolution {2 PublicListNode Merge (listnode list1,listnode list2) {3 if(list1==NULLlist2==NULL)return NULL;4
Linux several ways to list directories onlyUnder the Linux system, sometimes just want to list all the directories under the current path, such as:/lib directory files More, we just want to see the directory, then there are several ways to refer to:Method1. ls-f | grep '/$ '2. ls-l | grep ' ^d '3, NBSP;NBSP; Span style= "font-size:24px;font-family: ' Microsoft Jacob Black ', Sans-serif;color: #333333; background: #FFFF00;" >ls-ld*/ > Note: * denotes all files, plus/sub-directories. 4, NB
Command formatHistory [-c] [-D offset] [n]HISTORY-ANRW [filename]History-ps arg [arg...]Command parameters-CClears the History list.-D OffsetDelete the history entry numbered as offset.NDisplays the most recent N records.History extension
Sequence
Behavior
!!
Repeats the last command executed. Pressing the UP ARROW key and pressing the Enter key also enables the same functionality and is more consistent with the operating habits.
!number
Example: What is the result of printing the following program?1#include 2#include string>3 4 using namespacestd;5 6 class Base7 {8 Private:9 intm_i;Ten intM_j; One Public: A Base(inti): M_j (i), m_i (M_j); - Base(): M_j (0), M_i (M_j) {} - intGet_i () {returnm_i;} the intGet_j () {returnM_j;} - }; - intMainintargcChar*argv[]) - { + BaseObj98); -CoutEndl; +CoutEndl; A return 0; at}If you answer "98,98", it means you are not proficient in C + +, not familiar. Because the
intCompare (user O1, user O2) {returno1.getage (). CompareTo (O2.getage ()); } }}Results:Hello! My Name is Jessica and I ' M 20;i am 1 and i 'm ordered by Name Deschello! My Name is Abobo and I ' M 30;i am 2 and I 'm ordered by Name Deschello! My Name is Abobo and I ' M 30;i am 1 and i 'm ordered by Name Aschello! My Name is Jessica and I ' M 20;i am 2 and I 'm ordered by Name Aschello! My Name is Abobo and I ' M 30;i am 1 and i 'm orderedby age Deschello! My Name is Jessica and I '
Using system;using system.collections.generic;using system.linq;using system.text;namespace ListSort{class Program {static void Main (string[] args) {listTwo easy ways to sort lists
) {' name ': ' A ', ' gender ': ' Middle ', ' age ': 21}# find Print ( "Age" in dic) Trueprint (Dic.get ("Age") # or use (dic[' age ')) 21# Othersprint (Dic.values ()) print (Dic.keys ()) dict_ VALUES ([' A ', ' middle ', +]) dict_keys ([' Name ', ' gender ', ' age ']) # traversal # method 1for key in dic: print (key, Dic[key]) # method 2for K , V in Dic.items (): # will first turn the dict into a list, the data in the big time Mo with print (k, v)Weak slag I'll introduce you to the list
Scala Arrays and lists:Import Scala.collection.mutable.ArrayBufferimport scala.collection.mutable.Bufferobject arraylearning {def main ( Args:array[string]): Unit = {//usezipunzip//listops//arrayops//arraybufferops} private def Usezipunzip = {//zip and unzip Val nums = List (1, 2, 3, 4) Val chars = List (' A ', ' B ', ' C ', ' d ') val combinlist = Nums.zi P (chars) println (combinlist) println (Combinlist.unzip)} private def arraybufferops = {//create variable array val Strarra Yvar = array
Ideas:Known two pointers head1,head2;First define the returned pointer head;Compare the value of data in Head1, and head2, and assign a pointer with a smaller value to head.A current pointer is defined byAt this point current = head;Define P1, and the P2 pointer traverses two sequences respectively.If the two list is initialized, because the value of node 1 is less than the value of Node A, head = node 1,current = Node 1, p1 = node 2, p2 = Node A.Loops compare the values of the P1 and P2 nodes,
Import osdef count_subdir (src): listall = Os.listdir (src) for line in Listall: filepath = os.path.join (SRC, Line) if Os.path.isfile (filepath): listall.remove (line) return listall if __name__ = = "__main__": src = R ' f:\src ' ret = count_subdir (src) for line in RET: print LineOutput Result:Look at the end ... There are still files, and we compare the list of the original results that were not processed:The Final Document project, can be
"What is a list"Python's built-in list type is also a dataset type. In fact, like a string, a list is a sequence type, so there are some common features with strings. The difference between a list and a string is mainly in two ways:
A list can contain other elements, not just characters. In fact, a list can contain sequences of elements of any type, and even elements of different types can be mixed in the same list.
The list is a mutable type. This means that, unlike a string object, ch
One, the first Python appletFirst of all, we need to know that Python was founded on the original idea: Python is beautiful, clear and simple.So python requires less than half of the work done in other languages, as compared to Java Big Brother, who is now occupying the top of the language rankings: Public class helloworld:{ publicstatic void main (String [] args) { System.out.print ("Hello World") }} And the great Python just needs a magical line:Print ("helloWorld")Wh
1. Array to Liststring[] City = {"Nanjing", "Shanghai", "Beijing"}; ListNote: The list size of the array conversion is fixed, the Add, remove operation cannot be performed, or the following exception is thrown:Citylist.add ("Xiamen"); Citylist.remove (2);If you want to control the list size, you can only add the elements in the array to the list ...2. List Goto Arrayobject[] Cityarray = Citylist.toarray (); for (Object X:cityarray) System.out.println (x);Note: Since the list is converted to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.