当前位置:网站首页>蓝桥杯学习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;
}边栏推荐
- ELK 企业级日志分析系统
- Solution to the prompt of could not close zip file during phpword use
- 【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
- 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
- redis6事务和锁机制
- Can and can FD
- Wechat app payment callback processing method PHP logging method, notes. 2020/5/26
- Assembly language - Beginner's introduction
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- How to deal with the Yellow Icon during the installation of wampserver
猜你喜欢

Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法

Huawei push service content, read notes

Laravel框架运行报错:No application encryption key has been specified

那些考研后才知道的事

荐号 | 有趣的人都在看什么?

Solve the problem of invalid uni app configuration page and tabbar

Summit review | baowanda - an integrated data security protection system driven by compliance and security

我为什么支持 BAT 拆掉「AI 研究院」

What about data leakage? " Watson k'7 moves to eliminate security threats

RK3566添加LED
随机推荐
PostgreSQL Usage Summary (PIT)
Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
Nantong online communication group
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
Don't know these four caching modes, dare you say you understand caching?
What about data leakage? " Watson k'7 moves to eliminate security threats
不知道这4种缓存模式,敢说懂缓存吗?
NFT value and white paper acquisition
面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?
Integer ==比较会自动拆箱 该变量不能赋值为空
Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?
leetcode 10. Regular expression matching regular expression matching (difficult)
Solve the problem of "unable to open source file" xx.h "in the custom header file on vs from the source
Multi person cooperation project to see how many lines of code each person has written
Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
Laravel框架运行报错:No application encryption key has been specified
Solution to the prompt of could not close zip file during phpword use
2022司钻(钻井)考试题库及模拟考试
C object storage
Address book (linked list implementation)