L1-015 跟奥巴马一起画方块 (15 point(s))

  • 很神奇的字符串的初始化。

    string s(n, c);

    参考代码

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	char c;
	cin >> n >> c;
	string s(n, c);
	for(int i = 0; i < (n + 1) / 2; i++)
		cout << s << endl;
}
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	char c;
	cin >> n >> c;
	for(int i = 0; i < (n + 1) / 2; i++){
		for(int j = 0; j < n; j++)
			cout << c;
		cout << endl;
	}
}

posted on 2021-10-04 22:00  Atl212  阅读(80)  评论(0)    收藏  举报

导航