当前位置:网站首页>蓝桥杯学习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;
}边栏推荐
- Scientific running robot pancakeswap clip robot latest detailed tutorial
- 49. Grouping of alphabetic ectopic words: give you a string array, please combine the alphabetic ectopic words together. You can return a list of results in any order. An alphabetic ectopic word is a
- 不知道这4种缓存模式,敢说懂缓存吗?
- NFT value and white paper acquisition
- Summary and arrangement of JPA specifications
- Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
- MMSeg——Mutli-view时序数据检查与可视化
- 真正的缓存之王,Google Guava 只是弟弟
- 【MySQL 使用秘籍】一网打尽 MySQL 时间和日期类型与相关操作函数(三)
- Jetpack Compose入门到精通
猜你喜欢

华为推送服务内容,阅读笔记

这18个网站能让你的页面背景炫酷起来

Wonderful express | Tencent cloud database June issue

研究生可以不用学英语?只要考研英语或六级分数高!

redis6事务和锁机制

【华南理工大学】考研初试复试资料分享

一网打尽异步神器CompletableFuture

几款分布式数据库的对比

The real king of caching, Google guava is just a brother
![[South China University of technology] information sharing of postgraduate entrance examination and re examination](/img/a8/41e62a7a8d0a2e901e06c751c30291.jpg)
[South China University of technology] information sharing of postgraduate entrance examination and re examination
随机推荐
ELFK部署
Personal component - message prompt
Self built shooting range 2022
asp. Net read TXT file
What happened to the communication industry in the first half of this year?
Catch all asynchronous artifact completable future
French scholars: the explicability of counter attack under optimal transmission theory
龙芯派2代烧写PMON和重装系统
Jasypt configuration file encryption | quick start | actual combat
【云资源】云资源安全管理用什么软件好?为什么?
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
Liar report query collection network PHP source code
不知道这4种缓存模式,敢说懂缓存吗?
Resttemplate details
49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
Solve the problem of invalid uni app configuration page and tabbar
Ordering system based on wechat applet
The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
Require, require in PHP_ once、include、include_ Detailed explanation of the efficiency of repeated introduction of once class library