I just start learning array in c++, and i have a problem. The problem will input some array and i need to output it backwards.
ex:
input:
1
2
3
4
5
output:
5
4
3
2
1
Here is my code :
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,i,j;
int ar[25010];
i = 1;
while(scanf("%d",&a) != EOF)
{
ar[i] = a;
i = i+1;
}
for(j = i-1;j > 0;j--)
{
printf("%d \n",ar[j]);
}
}
I already submit it, but its still wrong.Is there some error in my code?
*sorry for bad english, thank you*