#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int a[25];
int k;
int main()
{
while(true)
{
int tmp;
scanf("%d",&tmp);
if(tmp==0)
break;
else
{
a[k++]=tmp;
}
}
for(int i=0,j=k-1;i<=j;i++,j--)
{
swap(a[i],a[j]);
}
for(int i=0;a[i];i++)
cout<<a[i]<<" ";
return 0;
}蓝桥杯算法提高 逆序排列
C++数组逆序输出
最新推荐文章于 2022-05-12 16:30:58 发布
本文展示了一个使用C++实现的简单程序,该程序通过数组输入一系列整数,并在接收结束标志0之后,将这些整数逆序输出。程序利用了标准C++库中的输入输出功能,并使用了一个简单的循环来实现数组元素的逆序交换。
338

被折叠的 条评论
为什么被折叠?



