当前位置:网站首页>Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
2022-07-02 06:06:00 【This question AC sleep again】
//
#include<bits/stdc++.h>
using namespace std;
const int MAXN=44;
char str[MAXN],ans[MAXN];
int anslen; // Redefinition of global variables
void init()
{
anslen=0;
memset( str,0,sizeof( str ) );
memset( ans,0,sizeof( ans ) );
}
bool judge()
{
char *p1=str;
char *p2=str+strlen(str)-1;
while( p1<p2 )
{
if( *p1!=*p2 ) return false;
p1++; p2--; //
}
return true;
}
void update()
{
int slen=strlen(str); // strlen name conflict
if( slen>anslen ) anslen=slen,strcpy( ans,str );
else if( slen==anslen )
{
if( strcmp( str,ans )>0 ) anslen=slen,strcpy( ans,str);
}
}
int main()
{
int n;
while( ~scanf("%d",&n) )
{
init();
while( n-- )
{
scanf("%s",str);
if( judge() ) update();
}
printf("%s\n",ans);
}
return 0;
}
//
find:
01 forget memcpy strncpy The use of
02 String always forgets when using first and last pointers displacement
03 str Character array len name Be careful and strlen name conflict
边栏推荐
- Format check JS
- Several keywords in C language
- 图片裁剪插件cropper.js
- Style modification of Mui bottom navigation
- External interrupts cannot be accessed. Just delete the code and restore it Record this unexpected bug
- Detailed notes of ES6
- Web页面用户分步操作引导插件driver.js
- Unity shader learning notes (3) URP rendering pipeline shaded PBR shader template (ASE optimized version)
- [paper translation] gcnet: non local networks meet squeeze exception networks and beyond
- From design delivery to development, easy and efficient!
猜你喜欢
神机百炼3.52-Prim
Stick to the big screen UI, finereport development diary
How vite is compatible with lower version browsers
Memcached installation
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')
Shenji Bailian 3.54-dichotomy of dyeing judgment
如何使用MITMPROXy
Deep learning classification network -- alexnet
社区说|Kotlin Flow 的原理与设计哲学
随机推荐
图片裁剪插件cropper.js
JWT工具类
步骤详解 | 助您轻松提交 Google Play 数据安全表单
PHP development and testing WebService (soap) -win
Jetpack Compose 与 Material You 常见问题解答
Nacos 启动报错 Error creating bean with name ‘instanceOperatorClientImpl‘ defined in URL
Some descriptions of Mipi protocol of LCD
Database learning summary 5
Ti millimeter wave radar learning (I)
token过期自动续费方案和实现
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
AttributeError: ‘str‘ object has no attribute ‘decode‘
ZABBIX server trap command injection vulnerability (cve-2017-2824)
让每一位开发者皆可使用机器学习技术
Redis key value database [seckill]
php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组
Style modification of Mui bottom navigation
STC8H8K系列汇编和C51实战——串口发送菜单界面选择不同功能
Deep learning classification network -- vggnet
Community theory | kotlin flow's principle and design philosophy