思路如下:
代码如下:
代码语言:javascript复制#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
//修剪灌木
//c解法
int main(int argc, char* argv[])
{
int n = 0;
int high = 0;
scanf("%d", &n);
printf("n");
for (int i = 1; i <= n; i )
{
if ((i - 1) * 2 > (n - i) * 2)
{
high = (i - 1) * 2;
printf("%dn", high);
}
else
{
high = (n - i) * 2;
printf("%dn", high);
}
}
return 0;
}
//c 解法
int main()
{
int n;
cin >> n;
cout<<endl;
for (int i = 1; i <= n; i )
{
cout << max(i - 1, n - i) * 2 << endl;
}
return 0;
}
加油各位!