[Simple recursive] [summary] exercises

poj2013
idea: since the beginning of the input is increasing so you can take advantage of this condition, no recursion, really want to take advantage of the full meaning of the questions ah. Where n i is the condition for the determination of the odd or even very harsh, very coherent.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;

string str[30];
int n;
int kase=0;

int main()
{
	while(cin>>n&&n)
	{
		printf("SET %d\n",++kase);
		for(int i = 1;i<=n;++i)
			cin>>str[i];
		for(int i=1;i<=n;i+=2)
			cout<<str[i]<<endl;
		for(int i=n-(n%2);i>1;i-=2)
			cout<<str[i]<<endl;
	}
	return 0;
}
Published 22 original articles · won praise 3 · Views 1837

Guess you like

Origin blog.csdn.net/qq_42825058/article/details/86751544