当前位置:网站首页>Blue Bridge Cup study 2022.7.5 (morning)
Blue Bridge Cup study 2022.7.5 (morning)
2022-07-05 13:49:00 【megaData】
String part :
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
string space = string(n-i,' ');
// Space
string ch = string(2*i-1,'A'+i-1);
// character
cout<<space+ch<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
char c;
cin>>c;
// The input is a number (1 To 9) Or letters (A To Z)
if(c>='A'&&c<='Z')
{
for(int i=1;i<=c-'A'+1;i++)
// Control the number of lines
{
for(int j=1;j<=c-'A'+1-i;j++)
{
cout<< " ";
}
// The output order of letters is to increase first and then decrease
for(int j=1;j<=i;j++)
{
cout<<(char)('A'+j-1);
}
for(int j=i-1;j>=1;j--)
{
cout<<(char)('A'+j-1);
}
cout<<endl;
}
}
else
{
for(int i=1;i<=c-'1'+1;i++)
{
for(int j=1;j<=c-'1'+1-i;j++)
{
cout<< " ";
}
for(int j=1;j<=i;j++)
{
cout<<(char)('1'+j-1);
}
for(int j=i-1;j>=1;j--)
{
cout<<(char)('1'+j-1);
}
cout<<endl;
}
}
return 0;
}
// Symmetric strings
#include<stdio.h>
#include<string.h>
char res[5000000];
int main()
{
int n;
scanf("%d",&n);
int len=0;
for(int i=1;i<=n;i++)
//0 To len-1
{
// stay len There is a space here
strcat(res+len+1 ,res);
res[len]='A'+i-1;
len=strlen(res);
}
printf("%s\n",res);
return 0;
}
//A
//ABA
//ABACABA
//ABACABADABACABA
#include<cstdio>
#include<cstring>
char s1[1005],s2[1005];
int main()
{
fgets(s1,1004,stdin);
fgets(s2,1004,stdin);
//fgets The length of the newline will be added at the end
int len1 = strlen(s1)-1,len2 = strlen(s2)-1;
// You need to subtract the length of the newline
int ans = 0;
for(int i=0;i+len2-1<len1;i++)
{
bool matched = true;
for(int j=0;j<len2;j++)
{
if(s1[i+j]!=s2[j])
{
matched=false;
break;
}
}
if(matched)
{
ans++;
}
}
printf("%d\n",ans);
return 0;
}
边栏推荐
- 法国学者:最优传输理论下对抗攻击可解释性探讨
- 搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
- The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
- When there are too many input boxes such as input transmitted at one time in the form, the post data is intercepted
- Redis6 master-slave replication and clustering
- 【云资源】云资源安全管理用什么软件好?为什么?
- PHP character capture notes 2020-09-14
- Elk enterprise log analysis system
- ETCD数据库源码分析——rawnode简单封装
- 53. Maximum subarray sum: give you an integer array num, please find a continuous subarray with the maximum sum (the subarray contains at least one element) and return its maximum sum.
猜你喜欢
Mmseg - Mutli view time series data inspection and visualization
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
【云资源】云资源安全管理用什么软件好?为什么?
Network security - Novice introduction
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
我为什么支持 BAT 拆掉「AI 研究院」
Convolutional Neural Networks简述
Summit review | baowanda - an integrated data security protection system driven by compliance and security
Kotlin协程利用CoroutineContext实现网络请求失败后重试逻辑
jasypt配置文件加密|快速入门|实战
随机推荐
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
These 18 websites can make your page background cool
Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
Selenium crawls Baidu pictures
Record in-depth learning - some bug handling
Don't know these four caching modes, dare you say you understand caching?
【华南理工大学】考研初试复试资料分享
js 从一个数组对象中取key 和value组成一个新的对象
Attack and defense world web WP
NFT value and white paper acquisition
Usage, installation and use of TortoiseSVN
几款分布式数据库的对比
Jetpack compose introduction to mastery
Source code analysis of etcd database -- peer RT of inter cluster network layer client
Win10——轻量级小工具
aspx 简单的用户登录
Parsing XML using Dom4j
Ordering system based on wechat applet
ETCD数据库源码分析——集群间网络层客户端peerRt