赞
踩
目录
2,P1317 - 我必须立刻签到,因为它有手就行http://www.haueacm.top/problem.php?id=1317
3, P1318 - OrzOrzOrz - HAUEOJ (haueacm.top)http://www.haueacm.top/problem.php?id=1318
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
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;
- }
本题主要考察递归,这题是比较简单的
- #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)//表达一个数的取值范围,要用和字符即&&
这道题需要注意一点的是,
若该编号的大佬是上述列出的大佬且出现过,则输出一个空格后输出"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,
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,
这道题把指令用二维数组存储就可以,注意二维数组定义位置,若放在main()函数中就会造成无法输入,就像这样
原因是在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;
- }
有手就行
- #include <stdio.h>
- int main()
- {
- for(int i = 1; i <= 1919; i ++)
- printf("114514\n");
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。