Data tem structure item itemitem --item tem X T1]VM2]·MN] item item A[M.N] 问题:如何遍历 floor 12 E “向量”和“数组”? : 四 30 30 348 Hotel analog gg… floor2 E floor I gg…g hotel room hotel corridor entire hotel Corresponding control structure instruction loop nested loops
问题:如何遍历 “向量”和“数组”?
Vector VS Loop In a way,a vector as a data structure is closely related to a loop as a control structure. Traversing a vector(for the purpose of inspection,search, summation,etc.)is typically carried out with a single iterative construct. Just as the loop is a control structure for describing lengthy processes,so is a vector a data structure for representing lengthy lists of data items
Vector VS Loop In a way, a vector as a data structure is closely related to a loop as a control structure. Traversing a vector (for the purpose of inspection, search, summation, etc.) is typically carried out with a single iterative construct. Just as the loop is a control structure for describing lengthy processes, so is a vector a data structure for representing lengthy lists of data items
Vector of vectors和Array有什么区别? item item item pointer item item item item item pointer item item item item item pointer item item item Array Vector of vectors inta[3][4]={K1,2,3,4},{5,6,7,8},{9,10,11,12}; printf(a[2][3]); printf(*(a[2])+3)); 从vector of vectors的角度看这个例子, printf(*(*(a+2)+3); 你是否更清晰了?
Vector of vectors和Array有什么区别? int a[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}}; printf(a[2][3]); printf(*(a[2])+3)); printf(*(*(a+2)+3)); 从vector of vectors的角度看这个例子, 你是否更清晰了?
问题:以下两者的区别何在? 在书架中取一本书 在一桶纸杯中拿一个杯子 In many applications of vectors and arrays,we do not need the full power provided by INDICES Sometimes a list is used just to model a queue. 使用时的随意性:任意存取 使用时的受限性:头存尾取 代价更高的数组才能实现如此的随意性 代价较低的队列就能实现受限的存取
在书架中取一本书 问题:以下两者的区别何在? 使用时的随意性:任意存取 使用时的受限性:头存尾取 代价更高的数组才能实现如此的随意性 代价较低的队列就能实现受限的存取 In many applications of vectors and arrays, we do not need the full power provided by INDICES. Sometimes a list is used just to model a queue. 在一桶纸杯中拿一个杯子
两种用途非常广泛的特殊Ls:队列、栈 it is worthwhile,at least for reasons of algorithmic clarity,to think of queues and stacks as being in themselves data structures,rather than being merely special kinds of lists. in out out back front Queue Stack a FIFO list(First-In-First-Out) a LIFO list(Last-In-First-Out) We can then use specially devised elementary instructions such as "add X to queue A,"or"push X on stack S,"rather than obscure formulations that explicitly involve indices
两种用途非常广泛的特殊List:队列、栈 a FIFO list (First-In-First-Out) a LIFO list (Last-In-First-Out) it is worthwhile, at least for reasons of algorithmic clarity, to think of queues and stacks as being in themselves data structures, rather than being merely special kinds of lists. We can then use specially devised elementary instructions such as “add X to queue A,” or “push X on stack S,” rather than obscure formulations that explicitly involve indices