东方博弈OJ/1211~1215解析

1211

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int a[15][15];
	int n, m;
	cin >> n >> m;
	int num = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			int judge1 = 0;
			int judge2 = 0;
			for (int k = 1; k <= m; k++)
			{
				if (a[i][k] < a[i][j])
				{
					judge1 = 1;
				}
			}
			for (int k = 1; k <= n; k++)
			{
				if (a[k][j] > a[i][j])
				{
					judge2 = 1;
				}
			}
			if (judge1 == 0 && judge2 == 0)
			{
				cout << i << " " << j << " " << a[i][j] << endl;
				num++;
			}
		}
	}
	if (num == 0)
	{
		cout << "not exist";
	}
	return 0;
}

1212 

#include <iostream>
using namespace std;
int main()
{
	int a[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int min = 2147483647;//int所能存储的最大值
	int min_sub;
	int max = -2147483647;
	int max_sub;
	for (int i = 0; i < n; i++)//找出最小数的下标
	{
		if (a[i] < min)
		{
			min = a[i];
			min_sub = i;
		}
	}
	for (int i = 0; i < n; i++)//找出最大数的下标
	{
		if (a[i] > max)
		{
			max = a[i];
			max_sub = i;
		}
	}
	int temp = a[0];//交换
	a[0] = a[min_sub];
	a[min_sub] = temp;
	temp = a[n - 1];
	a[n - 1] = a[max_sub];
	a[max_sub] = temp;
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	return 0;
}

感谢@always-like-a-star的答案

1213 

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int min = 2147483647;
	int min_sub;
	for (int i = 0; i < n; i++)
	{
		if (a[i] < min)
		{
			min = a[i];
			min_sub = i;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (i != min_sub)
		{
			cout << a[i] << " ";
		}
	}
	return 0;
}

 1214

#include <iostream>
using namespace std;
int main()
{
	int a[101];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int num;
	cin >> num;
	int max = -2147483647;
	int max_sub;
	for (int i = 0; i < n; i++)
	{
		if (a[i] > max)
		{
			max = a[i];
			max_sub = i;
		}
	}
	for (int i = n-1; i > max_sub; i--)
	{
		a[i + 1] = a[i];
	}
	a[max_sub + 1] = num;
	for (int i = 0; i < n + 1; i++)
	{
		cout << a[i] << " ";
	}
	return 0;
}

 1215

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[200];
	int num = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (a[i] > a[j])
			{
				num++;
			}
		}
	}
	cout << num;
}
  •  前段时间正在考蓝桥杯的省赛,耽误了些许时间。以后我尽量会做到一天一更或两天一谢谢!
  •   如果你喜欢我的博客可以点个赞支持一下。 
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值