你能区分这两个程序片段吗? int *pl,*p2; int *pl,*p2; *p1=44: *p1=44; *p2=99; *p2=99; p1=p2; *p1=*p2; print(*p1,*p2); print (*pl,*p2); 指针到底是什么? 两个不同的赋值到底区别在哪里?
int *p1, *p2; *p1=44; *p2=99; p1=p2; print(*p1,*p2); 你能区分这两个程序片段吗? int *p1, *p2; *p1=44; *p2=99; *p1=*p2; print(*p1,*p2); 指针到底是什么? 两个不同的赋值到底区别在哪里?
多个数据的聚集管理而出现的“结构” 场景:“一队士兵” ·每个士兵有了一个队伍中的唯一“位置” ·位置是相对的 如果设计一个按照位置进行的“游戏”,给定了位置 就指定了人 按照上述观点,vector/one-dimensional array为什 么被称为是一种数据结构,它的“结构性”体现在 哪里?
•场景:“一队士兵” • 每个士兵有了一个队伍中的唯一“位置” • 位置是相对的 • 如果设计一个按照位置进行的“游戏”,给定了位置 就指定了人 •按照上述观点,vector/one-dimensional array为什 么被称为是一种数据结构,它的“结构性”体现在 哪里? 多个数据的聚集管理而出现的“结构
改变“位置”和改变“内容” 24 78 浴 12.8 24 69 Bubble Sort 12 2 4 4 69 24 46896 14 46 冒泡排序 14 2 2412 14 8 26 14 4 12 sta时 end (1)do the following N-1 times: How to 1.1)X←-1: (1.2)while X N do the following: EXCHANGE (1.2.1)if V[X+1]V[X]then exchange them; (1.2.2)X←-X+1. them?
改变“位置”和改变“内容” How to EXCHANGE them? Bubble Sort 冒泡排序
Variable,Vector and Array Variable Vector Array A1,1] itemitem item Data item structure item itemitem item item X VI]I2]-·VN] item tem A[M.N] floor 12 30 302 348 Hotel analog 318 floor 2 floor 1 gg… hotel room hotel corridor entire hotel
Variable, Vector and Array
Variable Vector Array A1.11 item item tem 问题:如何访问 Data item structure tem itemitem item tem “单个变量”、“向 T11V2]·N] item item A[M.N] 量”和“数组”? floor 12 g… E : 30 30 348 Hotel analog .. floor2 E floor I g日…E 问题:如何遍历 hotel room hotel corridor entire hotel “单个变量”、“向 量”和“数组”? Corresponding control ■ structure instruction loop nested loops
问题:如何访问 “单个变量”、“向 量”和“数组”? 问题:如何遍历 “单个变量”、“向 量”和“数组”?