题目名字
小鱼的数字游戏
题目链接
https://www.luogu.com.cn/problem/P5436?contestId=147354
题意
小鱼最近被要求参加一个数字游戏,要求它把看到的一串数字 a i
(长度不一定,以 0 结束),记住了然后反着念出来(表示结束的数字 0 就不要念出来了)。这对小鱼的那点记忆力来说实在是太难了,你也不想想小鱼的整个脑袋才多大,其中一部分还是好吃的肉!所以请你帮小鱼编程解决这个问题
算法一:
时间复杂度
简单
代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[105];
int count=1,temp;
cin>>temp;
while(temp!=0)
{
a[count]=temp;
count++;
cin>>temp;
}
for(int i=count-1;i>=1;i--)
{
cout<<a[i]<<" ";
}
return 0;
}