从键盘输入数组a[n]各元素的值(以各人学号的每一位分别作为数组n个元素的值),采用指针访问方式将数组元素按逆序输出。

从键盘输入数组a[n]各元素的值(以各人学号的每一位分别作为数组n个元素的值),采用指针访问方式将数组元素按逆序输出。

#include<iostream>
using namespace std;
int main()
{
	int math[5];
	int i,j;
	int *p;
	p=math;
	for(i=1;i<=5;i++)
	{
		cin>>math[i];
	}
	for(p=math+5;p>math;p--)
	{
		cout<<*p<<" ";
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43803070/article/details/92791253