自考新教材--p60_5_1

源程序:

#include <iostream>

#include <string>

using namespace std;

int main()

{

  int n,i;

  cout << "输入几个字符串:";

  cin >> n;

  string *p;

  string *A = new string[n];

  p = A;

  cout << endl;

  cout << "请输入:";

  for (i = 0; i < n; i++)

    cin >> A[i];

  p = A;   //将指针重新指向数组的首地址

  cout << endl;

  cout << "您输入的字符串为:";

  for (i = 0; i < n; i++)

    cout << p[i]<<endl;

  delete []p;

  system("pause");

  return 0;

}

运行结果:

原文地址:https://www.cnblogs.com/duanqibo/p/11974621.html