2019年3月10日 天梯赛校选(解答)

题目:https://blog.csdn.net/qq_43591782/article/details/88417426

第一题

#include <iostream>
#include <cstring>

using namespace std;

int main() {
	int num = 0;
	char a[1001], b[1001];
	cin >> num;
	for (int i = 0; i < num; ++i) {
		cin >> a;
		cin >> b;
		if (strcmp(a, b) > 0)
			cout << ">" << endl;
		else if (strcmp(a, b) < 0)
			cout << "<" << endl;
		else
			cout << "=" << endl;
	}
	return 0;
}

第二题

#include <iostream>			//不确定

using namespace std;

int main()
{
	int num = 0;
	cin >> num;
	while (num--) {
		int m = 0, n = 0;
		cin >> n >> m;
		if (m >= n)
			cout << "Yes" << endl;
		else if (!(n % (m + 1)))
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
}

第三题

#include <iostream>						//找的板子
#include <string>
#include <vector>
#include <algorithm>
#include <stdexcept>
#define MAXN 1000

using namespace std;

int a[MAXN], b[MAXN];
int main(int argc, const char * argv[])
{
	int num = 0;
	cin >> num;
	while (num--) {
		string str1, str2;
		long int len1, len2;
		long int i, j, k;
		int up;

		cin >> str1 >> str2;
		len1 = str1.length();
		len2 = str2.length();
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		for (i = len1 - 1, k = 0; i != -1; --i)
		{
			a[k] = str1[i] - '0';
			k++;
		}
		for (j = len2 - 1, k = 0; j != -1; --j)
		{
			b[k] = str2[j] - '0';
			k++;
		}
		for (i = 0, up = 0; i < MAXN; ++i)
		{
			a[i] = a[i] + b[i] + up;
			up = a[i] / 10;
			a[i] %= 10;
		}
		for (i = MAXN - 1; i != -1; --i)
		{
			if (a[i])
			{
				break;
			}
		}
		for (k = i; k != -1; --k)
		{
			cout << a[k];
		}
		cout << endl;
	}
	return 0;
}

第四题(大数取模运算)

作者:LightAc
出处:https://www.cnblogs.com/lightac/
联系:
Email: dzz@stu.ouc.edu.cn
QQ: 1171613053
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/lightac/p/10534731.html