50(2023.12.20)(蓝桥杯入门练习1)

50(2023.12.20)(蓝桥杯入门练习1)_第1张图片

#include
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第2张图片

#include
using namespace std;
#include
int main()
{
	int n;
	cin >> n;
	int number=0;
	multisetmu;
	for (int i = 0;i < n;i++)
	{
		cin >> number;
		mu.insert(number);
	}
	for (multiset::iterator it = mu.begin();it != mu.end();it++)
	{
		cout << *it << " ";
	}
	cin >> n;
}

50(2023.12.20)(蓝桥杯入门练习1)_第3张图片

#include
using namespace std;
#include
#include

int main()
{
	string str;
	vectorv;
	int n;
	long long sum = 0;
	int start;
	int llx;
	vectorv1;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> str;
		v.push_back(str);
	}
	string str1;
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		llx = (*it).length();
		start = 1;
		sum = 0;
		v1.clear();
		for (int i = (llx-1);i >= 0;i--)
		{
			if ((int)(*it)[i] >= 48 && (int)(*it)[i] <= 57)
			{
				sum += (((int)(*it)[i] - 48) * (start));
				start *= 16;
			}
			else
			{
				sum += (((int)(*it)[i] - 55) * (start));
				start *= 16;
			}
		}
		while (sum!=0)
		{
			v1.insert(v1.begin(),sum % 8);
			sum /= 8;
		}
		for (vector::iterator itt = v1.begin();itt != v1.end();itt++)
		{
			cout << *itt;
		}
		cout << endl;

	}
	system("pause");
	return 0;
}
#include
using namespace std;
#include
#include
int arr[400000] = {};
int main()
{
	string str;
	vectorv;
	int n;
	int num;
	int start;
	int llx;
	vectorv1;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> str;
		v.push_back(str);
	}
	string str1;
	int times;
	int jin;
	int sum;
	vector::iterator pos;
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		llx = (*it).length();
		start = 1;
		v1.clear();
		times = 0;
		jin = 0;
		for (int i = (llx-1);i >= 0;i--)
		{
			if ((int)(*it)[i] >= 48 && (int)(*it)[i] <= 57)
			{
				num = ((int)(*it)[i] - 48);
				jin = times + 4;
				while (num != 0||times::iterator itt = pos;itt != v1.end();itt++)
		{
			cout << *itt;
		}
		cout << endl;
		v1.clear();
	}
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第4张图片 

 

#include
#include
#include
using namespace std;
int main()
{
	string str;
	cin >> str;
	long long sum = 0;
	long long start = 1;
	int l = str.length();
	vectorv;
	if (str == "0")
	{
		cout << 0;
		return 0;
	}
	for (int i = l - 1;i >= 0;i--)
	{
		if ((int)str[i] >= 48 && (int)str[i] <= 57)
		{
			sum += ((int)str[i] - 48) * start;
			start *= 16;
		}
		else
		{
			sum += ((int)str[i] - 55) * start;
			start *= 16;
		}
	}
	while (sum)
	{
		v.insert(v.begin(), sum % 10);
		sum /= 10;
	}
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		cout << *it;
	}
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第5张图片 

#include
#include
#include
using namespace std;
int main()
{
	long long num;
	cin >> num;
	vectorv;
	int flag;
	if (num == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	while (num != 0)
	{
		flag = num % 16;
		num /= 16;
		if (flag >= 0 && flag <= 9)
		{
			v.insert(v.begin(), (char)(flag+48));
		}
		else
		{
			v.insert(v.begin(), (char)(flag+55));
		}
	}
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		cout << *it;
	}
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第6张图片 

#include
using namespace std;
#include
int main()
{
	int n;
	cin >> n;
	multisetmu;
	int num;
	for (int i = 1;i < 10;i++)
	{
		for (int j = 0;j < 10;j++)
		{
			for (int z = 0;z < 10;z++)
			{
				if ((i * 2 + j * 2 + z * 2) == n)
				{
					num = i * 100000 + j * 10000 + z * 1000 + z * 100 + j * 10 + i;
					mu.insert(num);
				}
				else if ((i * 2 + j * 2 + z) == n)
				{
					num = i * 10000 + j * 1000 + z * 100 +  j * 10 + i;
					mu.insert(num);
				}
			}
		}
	}
	for (multiset::iterator it = mu.begin();it != mu.end();it++)
	{
		cout << *it << endl;
	}
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第7张图片 

 

#include
using namespace std;
int main()
{
	for (int i = 1;i <= 9;i++)
	{
		for (int j = 0;j <= 9;j++)
		{
			cout << i << j << j << i << endl;
		}
	}
	system("pause");
	return 0;
}

 50(2023.12.20)(蓝桥杯入门练习1)_第8张图片

 

#include
using namespace std;
int main()
{
	int a, b, c;
	for (int i = 100;i < 1000;i++)
	{
		a = i / 100;
		b = i / 10 - a * 10;
		c = i % 10;
		if (a*a*a+b*b*b+c*c*c == i)
		{
			cout << i << endl;
		}
	}
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第9张图片 

#include
using namespace std;
int main()
{
	int n;
	cin >> n;
	int arr[35][35] = {};
	arr[0][0] = 1;
	for (int i = 1;i < 35;i++)
	{
		for (int j = 0;j < 35;j++)
		{
			if (i - 1 >= 0 && j - 1 >= 0)arr[i][j] += arr[i - 1][j - 1];
			if (i - 1 >= 0)arr[i][j] += arr[i - 1][j];
		}
	}
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j <= i;j++)
		{
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}
	system("pause");
	return 0;
}

 50(2023.12.20)(蓝桥杯入门练习1)_第10张图片

#include
using namespace std;
#include
int main()
{
	int n;
	cin >> n;
	int num;
	vectorv;
	for (int i = 0;i < n;i++)
	{
		cin >> num;
		v.push_back(num);
	}
	int number;
	cin >> number;
	vector::iterator pos;
	pos = find(v.begin(), v.end(), number);
	if (pos != v.end())
	{
		cout << pos-v.begin()+1 << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	system("pause");
	return 0;
}
#include
using namespace std;
int main()
{
	int n;
	cin >> n;
	int arr[1001];
	int start = 1;
	int number;
	for (int i = 0;i < n;i++)
	{
		cin >> number;
		arr[i] = number;
	}
	cin >> number;
	for (int i = 0;i < n;i++)
	{
		if (number == arr[i])
		{
			cout << start;
			break;
		}
		start++;

	}
	if (start == n + 1)
	{
		cout << -1 << endl;
	}
	system("pause");
	return 0;
}

50(2023.12.20)(蓝桥杯入门练习1)_第11张图片 

#include
using namespace std;
int main()
{
	int n;
	cin >> n;
	int arr[10000] = {};
	int min = 10000;
	int max = -10000;
	int sum = 0;
	int number;
	for (int i = 0;i < n;i++)
	{
		cin >> number;
		if (number < min)min = number;
		if (number > max)max = number;
		sum += number;
	}
	cout << max << endl;
	cout << min << endl;
	cout << sum << endl;
	system("pause");
	return 0;
}

 50(2023.12.20)(蓝桥杯入门练习1)_第12张图片

#include
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int  arr[26][26] = {};
	int num = 65;
	int flag = 1;
	for (int i = 0;i < 26;i++)
	{
		flag = 1;
		num = 65 + i;
		for (int j = 0;j < 26;j++)
		{
			if (flag == 1)
			{
				arr[i][j] = num;
				if (num == 65)
				{
					num++;
					flag = 0;
				}
				else
				{
					num--;
				}
			}
			else if (flag == 0)
			{
				arr[i][j] = num;
				num++;
			}
		}
	}
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			cout << (char)(arr[i][j]);
		}
		cout << endl;
	}
	system("pause");
	return 0;
}

 

 

你可能感兴趣的:(算法)