1031 Hello World for U (20point(s)) Easy only once

基本思想:

考察数学基本不等式的内容,主要是缕清不等关系和最大关系,编程本身无难度;

 

关键点:

无;

 

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector> 
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
using std::vector;

int main() {
	string s;
	cin >> s;
	int n1, n2, n3;
	bool flag = true;
	n1 = n3 = (s.size() - 1) / 2;
	n2 = s.size() + 2 - n1 - n3;
	if (n1 > n2) {
		while (flag) {
			n1--;
			n3--;
			n2 += 2;
			//cout << n1 << endl << n2 << endl << n3 << endl;
			if (n1 <= n2) {
				flag = false;
			}
		}
	}
	for (int i = 0; i < n1 - 1; i++) {
		cout << s[i];
		for (int j = 0; j < n2 - 2; j++)
			cout << " ";
		cout << s[s.size()-1- i] << endl;
	}
	for (int i = n1 - 1; i < n1 - 1 + n2; i++) {
		cout << s[i];
	}
	system("pause");
	return 0;
}

  

posted @ 2020-01-15 15:29  暮云林凌  阅读(180)  评论(0)    收藏  举报