当前位置:网站首页>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
边栏推荐
- Stick to the big screen UI, finereport development diary
- 图片裁剪插件cropper.js
- Use some common functions of hbuilderx
- 我所理解的DRM显示框架
- 经典文献阅读之--Deformable DETR
- Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')
- 数据回放伴侣Rviz+plotjuggler
- Regular expression summary
- Detailed notes of ES6
- Web页面用户分步操作引导插件driver.js
猜你喜欢

Unity shader learning notes (3) URP rendering pipeline shaded PBR shader template (ASE optimized version)

如何使用MITMPROXy

DRM display framework as I understand it

在uni-app中引入uView

Deep learning classification network -- Network in network

Introduce uview into uni app

数据回放伴侣Rviz+plotjuggler
![[paper translation] gcnet: non local networks meet squeeze exception networks and beyond](/img/7a/718162d08796f70251511101b3a61b.png)
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond

ES6的详细注解

从设计交付到开发,轻松畅快高效率!
随机推荐
Community theory | kotlin flow's principle and design philosophy
Software testing - concept
深度学习分类网络 -- AlexNet
memcached安装
MySQL transaction and isolation level
Lambda 表达式 和 方法引用
[C language] screening method for prime numbers
Sumo tutorial Hello World
php数组转化为xml
Error creating bean with name 'instanceoperatorclientimpl' defined in URL when Nacos starts
Stc8h8k series assembly and C51 actual combat - digital display ADC, key serial port reply key number and ADC value
Vscode paste image plugin saves image path settings
Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')
Shenji Bailian 3.54-dichotomy of dyeing judgment
Memcached installation
Several keywords in C language
脑与认知神经科学Matlab Psytoolbox认知科学实验设计——实验设计四
Talking about MySQL database
Go 学习笔记整合
STC8H8K系列汇编和C51实战——按键允许按键计数(利用下降沿中断控制)