题解:::Contest1001 - 河南工程学院2022级新生周赛(一)

目录

1,1316: Hello , HAUE

2,P1317 - 我必须立刻签到,因为它有手就行http://www.haueacm.top/problem.php?id=1317

3, P1318 - OrzOrzOrz - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1318

5,

7,P1322 - 机器人OR寄器人 - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1322

8,P1321 - 帕秋莉GO!!! - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1321


 

1,1316: Hello , HAUE

P1316 - Hello , HAUE - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1316

考察输入输出,和if....else

#include <iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	if(N==1)
	cout<<"One Sail Wind Go"<<endl;
	if(N==6)
	cout<<"Six Six Big Go"<<endl;
	if(N==10)
	cout<<"Ten OK Ten OK"<<endl;
	if(N==2022)
	cout<<"Hello , HAUE"<<endl;
	return 0;
}

2,P1317 - 我必须立刻签到,因为它有手就行http://www.haueacm.top/problem.php?id=1317

 本题主要考察递归,这题是比较简单的

#include <iostream>
using namespace std;
int fun(long long x);
int main(){
	long long x;
	cin>>x;
	cout<<fun(x);
	return 0;
} 
int fun(long long x){
	if(x>=0&&x<=10)
	return x*x;
	if(x>10&&x<=50)
	return x*fun(x-5);
	if(x>50&&x<=100)
	return x+fun(x-10);
}

注意代码 

 if(x>=0&&x<=10)//表达一个数的取值范围,要用和字符即&&

3, P1318 - OrzOrzOrz - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1318

这道题需要注意一点的是,

若该编号的大佬是上述列出的大佬且出现过,则输出一个空格后输出"OrzOrzOrz"(不加引号)。 

当时没有注意,以为只是简单的查找,导致第一次没过 

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	char a[10005]; 
	char c;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<m;i++){
		int sum=0;
		cin>>c;
		for(int i=0;i<n;i++){
			if(c==a[i])
			sum++;
		}
		if(sum==0)
		cout<<sum<<endl;
		else {
	    if(c=='C'||c=='G'||c=='H'||c=='J'||c=='L'||c=='W'||c=='X'||c=='Y'||c=='Z')
		cout<<sum<<" "<<"OrzOrzOrz"<<endl;
		else
		cout<<sum<<endl;}
	}
	return 0;
}

注意代码 

if(c=='C'||c=='G'||c=='H'||c=='J'||c=='L'||c=='W'||c=='X'||c=='Y'||c=='Z')
		cout<<sum<<" "<<"OrzOrzOrz"<<endl;

4,

 

5,

P1320 - 不要停下来啊!!! - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1320方法一

#include <iostream>
using namespace std;
char a[100][100];
int main(){
	int n,m,k;
	int x,y;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
		a[i][j]='.';
	}
	for(int i=0;i<k;i++){
		cin>>x>>y;
		a[x][y]='#';
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

方法二 可以直接打表

6,

 

7,P1322 - 机器人OR寄器人 - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1322

这道题把指令用二维数组存储就可以,注意二维数组定义位置,若放在main()函数中就会造成无法输入,就像这样

2a1e86145e584ab09b22222bcc456f93.png

 原因是在main()中,计算机没有足够权限去开辟大的储存空间

#include <iostream> 
const int N=1000;
using namespace std;
int h[N][N];//指令存入二维数组 
int main(){
	int n,m,a,b,f;
	cin>>n>>m>>a>>b;
	for(int i=0;i<n;i++)
	for(int j=0;j<2;j++)
	cin>>h[i][j];
	for(int i=0;i<m;i++){
		cin>>f;
		a+=h[f-1][0];
		b+=h[f-1][1];
	}
	cout<<a<<" "<<b;
	return 0;
}

 

8,P1321 - 帕秋莉GO!!! - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1321

有手就行

#include <stdio.h> 
int main()
{ 
for(int i = 1; i <= 1919; i ++) 
printf("114514\n");
return 0; 
}

 

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
你好!对于扫雷游戏的题解,我可以给你一些思路和代码示例。首先,你需要了解扫雷游戏的规则和要求。接下来,你可以使用C++语言来实现游戏逻辑和界面。 下面是一个简单的扫雷游戏的C++代码示例: ```cpp #include <iostream> #include <vector> #include <random> using namespace std; class MinesweeperGame { private: int rows; int cols; vector<vector<char>> board; vector<vector<bool>> revealed; vector<pair<int, int>> directions = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; public: MinesweeperGame(int m, int n, int mineCount) { rows = m; cols = n; board.resize(rows, vector<char>(cols, ' ')); revealed.resize(rows, vector<bool>(cols, false)); placeMines(mineCount); calculateNumbers(); } void printBoard() { cout << " "; for (int j = 0; j < cols; j++) { cout << j << " "; } cout << endl; for (int i = 0; i < rows; i++) { cout << i << " |"; for (int j = 0; j < cols; j++) { cout << board[i][j] << "|"; } cout << endl; } } bool isGameOver() { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (board[i][j] == 'M' && revealed[i][j]) { return true; } } } return false; } void reveal(int row, int col) { if (row < 0 || row >= rows || col < 0 || col >= cols || revealed[row][col]) { return; } revealed[row][col] = true; if (board[row][col] == 'M') { return; } if (board[row][col] == '0') { for (auto dir : directions) { reveal(row + dir.first, col + dir.second); } } } private: void placeMines(int mineCount) { random_device rd; mt1

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

算法第一深情

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

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

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

打赏作者

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

抵扣说明:

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

余额充值