---
# System prepended metadata

title: 指標與多維陣列題目練習(必看)

---

# 指標與多維陣列題目練習(必看)
[指標與多維陣列題目答案](/q7rQn7jfSaGtLL9vMqmZxQ)
[指標閱讀](https://wellbay.cc/thread-1991596.htm)

## 第一題
``` c=
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
double *tmp;
double data[4][4]={{5,4,12,17},{9,10,31, 21},{7, 14,12, 8},{27,34,42,18}};
tmp = data[3];
cout << *tmp <<endl;
cout << (--tmp)[4] << endl;
cout << ++(--tmp)[1] <<endl;
cout << ++*(data+2)[0] <<endl; 
cout << --tmp++[-7] <<endl;

	return 0;
  }
```

## 第二題
``` c=
#include <iostream>
#include <stdio.h>
#include <stdlib,h>

int main(){
double *ptr;
double array[3][4]={{10,11,12,13},{4,5,6,7},{18, 19,20,21}};
ptr =(int*)array;
printf("%d\n",array[1][2]);
ptr++;
printf("%d\n", *ptr);
printf("%d\n %d\n",(*(array+1))[1],*((array+1)[1]));
ptr++;
printf("%d\n", *ptr);
system("pause");
return 0;

  }
```

## 第三題

``` c=
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
double *tmp;
double data[4][3]={{1,3,10},{7,10,11},{2, 12,
6},{9,9,14};
tmp = data[1];
cout << data[2][2] <<endl;
cout << tmp[1] << endl;
cout << ++*(data+2)[0] <<endl;
cout << --tmp++[0] <<endl;

	return 0;
  }

```

## 第四題

``` c=
#include <iostream>
#include <stdio.h>
#include <stdlib,h>

int main(){
int arr[] ={100,200,300,400,500};
int *ptr = arr+1;
printf("%d/n", *(ptr+1));
printf("%d/n", *(ptr)+1);
printf("%d/n", ptr[2]+1);
printf("%d/n", *(arr+1));
printf("%d/n", arr[3]+1);
return 0;
  }
``` 

## 第五題
``` c=
#include <iostream>
#include <stdio.h>
#include <stdlib,h>

int main(){
char *str[4] ={"Taipai","London","Berlin","Tokyo"};
printf("%d/n", *(*(str+1)));
printf("%d/n", *(str[3]+1)); //感覺怪怪的
printf("%d/n", *(*(str+2))+1); //感覺怪怪的
return 0;
  }
  ```
  呈上題，如何印出"Tokyo"字串中的y字元?如何印出"Berlin"的子字串"lin"
  
 ## 第六題
 
在int list[8]中，list[i] = i+3，對於i = 0....7;&(list[6])為0x123456
(A)*(list+5)為:
(B) (list+2)為:

## 第七題

```  c++=
#include<iostream>
void main(){
    double * pdata;
    double data[3][5] = {{1,3,4,5,10},{7,8,9,10,11},{2,12,6,15,14}};
    pdata = data[1];
    cout<<data[2][4]<<endl;
    cout<<pdata[3]<<endl;
    cout<<*(data+1)[1]+3<<endl;
    cout<<pdata--[0]<<endl;
}

```

## 第八題
``` java=
 char *arr = (char*) malloc (6*sizeof(char));
 /* the address of the first char in the array is 0x3000*/
/* arr:[0x3000] --> ['A']['I']['U']['E']['O']['\0']*/
(NOTE that the space of each character is 2byte.)
```
(a)arr+5=?
(b)*(arr+4)=?
(c)arr[2]=?
(d)&arr[2]=?
(e)(*arr)+1=?

![](https://i.imgur.com/ouZTmv4.png)
