当前位置:网站首页>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
边栏推荐
- PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
- Redis Key-Value数据库【初级】
- AttributeError: ‘str‘ object has no attribute ‘decode‘
- JWT tool class
- [PHP是否安装了 SOAP 扩]对于php实现soap代理的一个常见问题:Class ‘SoapClient‘ not found in PHP的处理方法
- Leverage Google cloud infrastructure and landing area to build enterprise level cloud native excellent operation capability
- 穀歌出海創業加速器報名倒計時 3 天,創業人闖關指南提前收藏!
- 500. 键盘行
- 借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力
- 【C语言】简单实现扫雷游戏
猜你喜欢

ESP8266与STC8H8K单片机联动——天气时钟

keepalived安装使用与快速入门

From design delivery to development, easy and efficient!

Comment utiliser mitmproxy

Compte à rebours de 3 jours pour l'inscription à l'accélérateur de démarrage Google Sea, Guide de démarrage collecté à l'avance!

Test case

【C语言】简单实现扫雷游戏

Problems encountered in uni app development (continuous update)

Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')

The official zero foundation introduction jetpack compose Chinese course is coming!
随机推荐
PHP read file (read the specified line containing a string in the file)
Test case
深度学习分类网络--Network in Network
PHP 开发与测试 Webservice(SOAP)-Win
Compte à rebours de 3 jours pour l'inscription à l'accélérateur de démarrage Google Sea, Guide de démarrage collecté à l'avance!
php获取cpu使用率、硬盘使用、内存使用
Jetpack Compose 与 Material You 常见问题解答
495.提莫攻击
神机百炼3.52-Prim
uni-app开发中遇到的问题(持续更新)
网络相关知识(硬件工程师)
Lambda 表达式 和 方法引用
Linkage between esp8266 and stc8h8k single chip microcomputer - Weather Clock
官方零基础入门 Jetpack Compose 的中文课程来啦!
PHP parent
TI毫米波雷达学习(一)
Can't the dist packaged by vite be opened directly in the browser
memcached安装
格式校验js
穀歌出海創業加速器報名倒計時 3 天,創業人闖關指南提前收藏!