当前位置:网站首页>蓝桥杯学习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;
}
边栏推荐
- About the problem and solution of 403 error in wampserver
- js 从一个数组对象中取key 和value组成一个新的对象
- mysql获得时间
- When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
- Etcd database source code analysis -- rawnode simple package
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
- Source code analysis of etcd database -- peer RT of inter cluster network layer client
- Programmer growth Chapter 8: do a good job of testing
- Hide Chinese name
- Summary and arrangement of JPA specifications
猜你喜欢
几款分布式数据库的对比
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
ZABBIX monitoring
Primary code audit [no dolls (modification)] assessment
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
NFT value and white paper acquisition
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
Record in-depth learning - some bug handling
C object storage
The development of speech recognition app with uni app is simple and fast.
随机推荐
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
Set up a website with a sense of ceremony, and post it to the public 2/2 through the intranet
Those things I didn't know until I took the postgraduate entrance examination
Redis6 master-slave replication and clustering
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
These 18 websites can make your page background cool
Idea设置方法注释和类注释
Source code analysis of etcd database -- peer RT of inter cluster network layer client
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
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
运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
Pancake Bulldog robot V2 (code optimized)
What is information security? What is included? What is the difference with network security?
Programmer growth Chapter 8: do a good job of testing
Integer ==比较会自动拆箱 该变量不能赋值为空
STM32 reverse entry
Can and can FD
Primary code audit [no dolls (modification)] assessment
:: ffff:192.168.31.101 what address is it?
ETCD数据库源码分析——rawnode简单封装