团体程序设计天梯赛 L1-036~L1-040

L1-036

思路:

相乘输出即可

代码:

#include<bits/stdc++.h>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}

L1-037

思路:

按格式输出即可

代码:

#include<bits/stdc++.h>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	printf("%d/", a);
	if(b < 0) printf("(%d)=", b);
	else printf("%d=", b);
	if(b){	printf("%.2f", a * 1.0 / b); }
	else puts("Error");
	return 0;
}

L1-038

思路:

输出即可

代码:

#include<bits/stdc++.h>

using namespace std;

int main() {
	puts("Hello World");
	puts("Hello New World");
	return 0;
}

L1-039

思路:

稍微找一下规律,输出即可

代码:

#include<bits/stdc++.h>

using namespace std;

int main() {
	int n; cin >> n; getchar();
	string s; getline(cin, s);
	int len = s.length(), pos = len - 1;
	while(pos % n) --pos;
	for(int i = 0; i < n; i++){
		for(int st = pos++; st >= 0; st -= n)
			putchar(st < len ? s[st] : ' ');
		putchar('\n');
	}
	return 0;
}

L1-040

思路:

判断相乘或者相除
找一个161的女朋友有没

代码:

#include<bits/stdc++.h>

using namespace std;

int main() {
	int kase;
	cin >> kase;
	while(kase--){
		char c;
		double h;
		cin >> c >> h;
		if(c == 'M') printf("%.2f\n", h / 1.09);
		else printf("%.2f\n", h * 1.09);
	}
	return 0;
}
posted @ 2020-01-16 18:15  YuhanのBlog  阅读(101)  评论(0编辑  收藏  举报