ncccu 11.26 比赛代码

1

#include <iostream>

using namespace std;

class Time {
private:
	int h, m, s;
public:
	Time(int _h, int _m, int _s): h(_h), m(_m), s(_s) {}
	void addTime(int _h, int _m, int _s) {
		this->s += _s;
		if (this->s >= 60) this->m ++, this->s -= 60;
		this->m += _m;
		if (this->m >= 60) this->h ++, this->m -= 60;
		this->h += _h;
		this->h %= 24;
	}
	void minusTime(int _h, int _m, int _s) {
		this->s -= _s;
		if (this->s < 0) this->m --, this->s += 60;
		this->m -= _m;
		if (this->m < 0) this->h --, this->m += 60;
		this->h -= _h;
		(this->h += 24) %= 24;
	}
	void time12() {
		int hh = this->h;
		if (hh == 0) hh = 12;
		if (hh > 12) hh -= 12;
		printf("%02d:%02d:%02d ", hh, this->m, this->s);
		cout << (this->h < 12 ? "AM" : "PM") << endl;
	}
	void time24() { printf("%02d:%02d:%02d", this->h, this->m, this->s); }
	void output() {
		this->time12();
		this->time24();
	}
};

int main() {
	int h, m, s; cin >> h >> m >> s;
	Time a(h, m, s);
	a.output();
	cout << endl;
	cin >> h >> m >> s;
	a.addTime(h, m, s);
	a.output();
	cout << endl;
	cin >> h >> m >> s;
	a.minusTime(h, m, s);
	a.output();
	return 0;
}

2

#include <iostream>

using namespace std;

int main() {
	string s;
	string a = "aeiouAEIOU";
	getline(cin, s);
	string ans;
	int n = s.size(), cnt = 0;
	for (int i = 0; i < n; i ++) {
		bool ok = false;
		for (int j = 0; j < 10; j ++) {
			if (s[i] == a[j]) {
				ok = true;
			}
		}
		if (!ok) ans += s[i];
		else cnt ++;
	}
	cout << cnt << endl << ans;
	return 0;
}

3

#include <iostream>

using namespace std;

const int N = 1e6 + 2;
const string yes = "The input array is a max heap.";
const string no = "The input array is not a max heap.";
int n, a[N];

int main() {
	bool ok = true;
	while (~scanf("%d", &a[++ n]));
	n --;
	for (int i = 1; i <= n; i ++) {
		if (i * 2 <= n) {
			if (a[i * 2] > a[i]) {
				ok = false;
				break;
			}
		}
		if (i * 2 + 1 <= n) {
			if (a[i * 2 + 1] > a[i]) {
				ok = false;
				break;
			}
		}
	}
	cout << (ok ? yes : no) << endl;
	return 0;
}

4

#include <iostream>

using namespace std;

int main() {
	double n, k; cin >> n >> k;
	double m = 150;
	for (int i = 1; i <= 10; i ++) {
		m *= 1 + k / 100;
		if (n * i >= m) {
			printf("%d %.2lf", i, m);
			return 0;
		}
	}
	cout << "Impossible";
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JorbanS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值