#include<iostream>
#include<algorithm>
using namespace std;

void Print(int b,int t) {
	if (b % 2) {
		int i = b / 2;
		while (i >= 1) {
			cout << t - i<<" ";
			i--;
		}
		i = 1;
		cout << t << " ";
		while (i <= b / 2)
		{
			cout << t + i << " ";
			i++;
		}
		cout << endl;
	}
	if (t % 2 && b - t / 2 > 0) {
		int i = t / 2;
		while (i>=1){
			cout << b - i << " ";
			i--;
		}
		i = 1;
		cout << b << " ";
		while (i<=t/2)
		{
			cout << b + i << " ";
			i++;
		}
		cout << endl;
	}
}

void Find(int s) {
	int t = 2;
	while (t<=sqrt(s))
	{
		if (s%t==0) {
			int b = s / t;
			Print(t,b);
		}
		t++;
	}
}

int main() {
	Find(24);
	return 0;
}

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐