#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int f = (sqrt(8 * n + 1) - 1) / 2;
for (int i = 1;i <= f;++i) {
int m = (i*(i + 1)) / 2;
cout << s[m - 1];
}
//system("pause");
return 0;
}
本文分享了一段使用C++编程语言实现的程序代码,该程序能够读取一个整数并计算出对应的数学序列,然后从序列中选择特定元素进行打印。通过使用平方根和循环结构,程序有效地找到了序列中的元素位置。
328

被折叠的 条评论
为什么被折叠?



