codeforce -Repeating Cipher

codeforce -Repeating Cipher

典型的签到题,一个for循环,取第1,1+2,1+2+3,1+2+3+4个数并输出
具体看代码:

// An highlighted block
#include<cstdio>
#include <iostream>
using namespace std;

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	char ch[100];
	cin>>n;
	cin>>ch;
	int c = 1;
	for (int i = 0; i<n; i += c){
		cout<<ch[i];
		c++;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42580946/article/details/85498301
今日推荐