ITP1_6_A: Reversing Numbers

Array - Reversing Numbers


与えられた数列を逆順に出力するプログラムを作成。

#include <stdio.h>
#include <stack>

	

int main()
{
int n,a;
std::stack<int> stc;
scanf("%d",&n);
while(n--){
	scanf("%d",&a);
	stc.push(a);
}
n=stc.top();
stc.pop();
printf("%d",n);
	while(!stc.empty()){
		printf(" %d",stc.top());
		stc.pop();
	}
	printf("\n");
}
最終更新:2016年03月19日 09:39