# 移动数组中的字符

在数组中有n个字符，使前面各字符顺序向后移动m个位置，并使最后m个字符变成最前面的 m 个字符

以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include <iostream>
using namespace std;
void funShift(int m, char *p, int n)
{
    char c;
    for (int j = 0; j < m; j++)
    {
		_____________________;
    }
}
int main()
{
    int i, m, n;
    cin >> m >> n;
    char *p = new char[n + 1];
    p[n] = 0;
    for (i = 0; i < n; ++i)
        cin >> p[i];
    funShift(m, p, n);
    for (i = 0; i < n; ++i)
        cout << p[i] << ' ';
    cout << endl;
    delete[] p;
    getchar();
    getchar();
    return 0;
}
```


## template

```cpp
#include <iostream>
using namespace std;
void funShift(int m, char *p, int n)
{
    char c;
    for (int j = 0; j < m; j++)
    {
        c = p[n - 1];
        for (int i = n - 1; i > 0; i--)
        {
            p[i] = p[i - 1];
        }
        p[0] = c;
    }
}
int main()
{
    int i, m, n;
    cin >> m >> n;
    char *p = new char[n + 1];
    p[n] = 0;
    for (i = 0; i < n; ++i)
        cin >> p[i];
    funShift(m, p, n);
    for (i = 0; i < n; ++i)
        cout << p[i] << ' ';
    cout << endl;
    delete[] p;
    getchar();
    getchar();
    return 0;
}
```

## 答案

```cpp
c = p[n - 1];
for (int i = n - 1; i > 0; i--)
{
	p[i] = p[i - 1];
}
p[0] = c;
```

## 选项

### A

```cpp
c = p[n];
for (int i = n - 1; i > 0; i--)
{
	p[i] = p[i - 1];
}
p[0] = c;
```

### B

```cpp
c = p[n - 1];
for (int i = n - 1; i > 0; i--)
{
	p[i] = p[i + 1];
}
p[0] = c;
```

### C

```cpp
c = p[n];
for (int i = n - 1; i > 0; i--)
{
	p[i] = p[i + 1];
}
p[0] = c;
```