当前位置:网站首页>蓝桥杯学习2022.7.5(上午)
蓝桥杯学习2022.7.5(上午)
2022-07-05 13:48:00 【megaData】
字符串部分:
#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,' ');
//空格
string ch = string(2*i-1,'A'+i-1);
//字符
cout<<space+ch<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
char c;
cin>>c;
//输入的是数字(1到9)或者字母(A到Z)
if(c>='A'&&c<='Z')
{
for(int i=1;i<=c-'A'+1;i++)
//控制行数
{
for(int j=1;j<=c-'A'+1-i;j++)
{
cout<< " ";
}
//字母输出顺序是先增加后减小
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;
}
//对称字符串
#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 到 len-1
{
//在len这里空一个位置
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会在最后加入换行的长度
int len1 = strlen(s1)-1,len2 = strlen(s2)-1;
//需要减去换行的长度
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;
}
边栏推荐
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
- ETCD数据库源码分析——rawnode简单封装
- MySQL - database query - sort query, paging query
- 【MySQL 使用秘籍】一网打尽 MySQL 时间和日期类型与相关操作函数(三)
- MySQL get time
- 研究生可以不用学英语?只要考研英语或六级分数高!
- Scientific running robot pancakeswap clip robot latest detailed tutorial
- 【公开课预告】:视频质量评价基础与实践
- Personal component - message prompt
- :: ffff:192.168.31.101 what address is it?
猜你喜欢
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
记录一下在深度学习-一些bug处理
那些考研后才知道的事
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
PHP basic syntax
Cloudcompare - point cloud slice
Rk3566 add LED
Nantong online communication group
真正的缓存之王,Google Guava 只是弟弟
随机推荐
French scholars: the explicability of counter attack under optimal transmission theory
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
Apicloud studio3 WiFi real machine synchronization and WiFi real machine preview instructions
Laravel framework operation error: no application encryption key has been specified
uplad_ Labs first three levels
[cloud resources] what software is good for cloud resource security management? Why?
redis6数据类型及操作总结
Redis6 master-slave replication and clustering
53. 最大子数组和:给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
Idea设置方法注释和类注释
嵌入式软件架构设计-消息交互
Laravel框架运行报错:No application encryption key has been specified
ETCD数据库源码分析——集群间网络层客户端peerRt
MMSeg——Mutli-view时序数据检查与可视化
Require, require in PHP_ once、include、include_ Detailed explanation of the efficiency of repeated introduction of once class library
Summary and arrangement of JPA specifications
Wonderful express | Tencent cloud database June issue
私有地址有那些
STM32 reverse entry