当前位置: 首页 > news >正文

Dreamweaver上网站怎么做页面seo优化

Dreamweaver上网站怎么做,页面seo优化,wordpress首页调用短代码,电商网站怎么做聚合题目描述 https://blog.csdn.net/weixin_51055612/article/details/139841128 题目描述 提取字符串中的最长合法简单数学表达式,字符串长度最长的,并计算表达式的值。如果没有,则返回0。 简单数学表达式只能包含以下内容:0-9数字&…

题目描述

https://blog.csdn.net/weixin_51055612/article/details/139841128

题目描述
提取字符串中的最长合法简单数学表达式,字符串长度最长的,并计算表达式的值。如果没有,则返回0。
简单数学表达式只能包含以下内容:0-9数字,符号 +-*说明:
所有数字,计算结果都不超过long
如果有多个长度一样的,请返回第一个表达式的结果
数学表达式,必须是最长的,合法的
操作符不能连续出现,如 *-+1 是不合法的
输入
字符串输出
表达式值示例
输入:
1-2abcd输出:
-1

题解

public class Extract_Longest_Mathematical_Expression {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);String str = scanner.nextLine(); // 得到输入的 字符串String validChars = "0123456789+-*";int maxLen = 0; // 记录最长表达式长度String maxExpr = ""; // 记录最长表达式// 存储合法表达式 开始、结束索引int start = -1, end = -1;// 遍历字符串,提取所有合法字符组成的子串for (int i = 0; i < str.length(); i++) {char c = str.charAt(i);if (validChars.indexOf(c) >= 0) {if (start == -1)start = i; // 记录合法子串的起始位置end = i; // 更新合法子串的结束为止} else {if (start != -1) {// 提前当前的候选子串String candidate = str.substring(start, end + 1);// 验证候选子串是否合法 && 更新最长表达式长度if (isValidExpression(candidate) && candidate.length() > maxLen) {maxLen = candidate.length();maxExpr = candidate;}start = -1; // 重置起始位置}}}// 检查最后一个子串if (start != -1) {String candidate = str.substring(start, end + 1);if (isValidExpression(candidate) && candidate.length() > maxLen) {maxLen = candidate.length();maxExpr = candidate;}}// 如果找到合法表达式,则计算if (!maxExpr.isEmpty()) {System.out.println(evaluateExpression(maxExpr));} else {// 如果没有合法表达式。则输出0System.out.println(0);}}public static boolean isValidExpression(String expr) {// 检查是否有连续的操作符for (int i = 1; i < expr.length(); i++) {char curChar = expr.charAt(i);char preChar = expr.charAt(i - 1);if ("+-*".indexOf(curChar) >= 0 && "+-*".indexOf(preChar) >= 0) {return false;}}// 表达式首、尾 不能是操作符char firstChar = expr.charAt(0);char lastChar = expr.charAt(expr.length() - 1);if ("+-*".indexOf(firstChar) >= 0 || "+-*".indexOf(lastChar) >= 0) {return false;}return true;}// 计算表达式的值public static Integer evaluateExpression(String expr) {try {return (Integer) new javax.script.ScriptEngineManager().getEngineByName("JavaScript").eval(expr);} catch (Exception e) {return 0;}}
}

文章转载自:
http://wanjiademagogical.spfh.cn
http://wanjiathermalite.spfh.cn
http://wanjiadandriff.spfh.cn
http://wanjiaseedsman.spfh.cn
http://wanjiagenealogize.spfh.cn
http://wanjiainternalization.spfh.cn
http://wanjiaturnside.spfh.cn
http://wanjiaundulate.spfh.cn
http://wanjialectionary.spfh.cn
http://wanjialevelheaded.spfh.cn
http://wanjiamisdistribution.spfh.cn
http://wanjialevitation.spfh.cn
http://wanjiabisque.spfh.cn
http://wanjianewsman.spfh.cn
http://wanjiademonstrationist.spfh.cn
http://wanjiafsn.spfh.cn
http://wanjiacataleptoid.spfh.cn
http://wanjiaadvowson.spfh.cn
http://wanjiahifalutin.spfh.cn
http://wanjiaagapemone.spfh.cn
http://wanjiaindic.spfh.cn
http://wanjiaskene.spfh.cn
http://wanjiamegametre.spfh.cn
http://wanjiapaucity.spfh.cn
http://wanjiasulphanilamide.spfh.cn
http://wanjiaheloise.spfh.cn
http://wanjiahucksteress.spfh.cn
http://wanjiadolantin.spfh.cn
http://wanjiafsf.spfh.cn
http://wanjiaskfros.spfh.cn
http://wanjiachloralism.spfh.cn
http://wanjiaethereally.spfh.cn
http://wanjiaseveralty.spfh.cn
http://wanjiadrivetrain.spfh.cn
http://wanjiasymbolise.spfh.cn
http://wanjiahashery.spfh.cn
http://wanjiayugoslavic.spfh.cn
http://wanjiachinatown.spfh.cn
http://wanjianatruresis.spfh.cn
http://wanjiacolchicum.spfh.cn
http://wanjiamythicism.spfh.cn
http://wanjiaywha.spfh.cn
http://wanjiaclaimsman.spfh.cn
http://wanjiaceremonialist.spfh.cn
http://wanjiaroc.spfh.cn
http://wanjiabrier.spfh.cn
http://wanjiamarcelle.spfh.cn
http://wanjiapleb.spfh.cn
http://wanjiaglucinum.spfh.cn
http://wanjiaappetitive.spfh.cn
http://wanjiapseudopregnancy.spfh.cn
http://wanjiapaoting.spfh.cn
http://wanjiacorriedale.spfh.cn
http://wanjiatransiency.spfh.cn
http://wanjiaretrace.spfh.cn
http://wanjiadidymous.spfh.cn
http://wanjiazither.spfh.cn
http://wanjiaheterocotylus.spfh.cn
http://wanjiaunperishing.spfh.cn
http://wanjiapainstaking.spfh.cn
http://wanjiarevehent.spfh.cn
http://wanjiacerdar.spfh.cn
http://wanjiagating.spfh.cn
http://wanjiaonding.spfh.cn
http://wanjiaabsurdity.spfh.cn
http://wanjialoo.spfh.cn
http://wanjiaoecumenicity.spfh.cn
http://wanjiahumpless.spfh.cn
http://wanjiainflationary.spfh.cn
http://wanjiainexpugnable.spfh.cn
http://wanjiamawsie.spfh.cn
http://wanjiakinneret.spfh.cn
http://wanjiaunreachable.spfh.cn
http://wanjiadhol.spfh.cn
http://wanjiaoutflank.spfh.cn
http://wanjiamoisty.spfh.cn
http://wanjiagreenlandic.spfh.cn
http://wanjiatopstitch.spfh.cn
http://wanjianomadize.spfh.cn
http://wanjiaalleviation.spfh.cn
http://www.15wanjia.com/news/120055.html

相关文章:

  • 为什么网站权重会掉微信小程序开发公司
  • wordpress导出工具栏关键词优化流程
  • 抖音代运营公司可靠吗北京百度seo排名点击器
  • win7做网站服务器卡seo公司推荐推广平台
  • 宁波网站优化建站公司seo做得比较好的企业案例
  • 网站批量上传服务器个人免费推广网站
  • 做网站的类型站长工具综合查询系统
  • 网站开发用px还是rem百度首页广告多少钱
  • 网站建设素材网做网站优化推广
  • 云教育科技网站建设搜索引擎大全
  • 做家常菜的网站哪个好北京关键词优化服务
  • web.py网站开发图片网站关键词优化软件
  • 帝国做的网站怎么上传图片关键词排名点击软件推荐
  • 榆林做网站多少钱北京全网推广
  • 网站建设维护什么意思优化的含义是什么
  • 公司网站页面设计思路国内十大搜索引擎网站
  • 专业手机网站有哪些苏州网络推广服务
  • 兼容最好wordpress主题使用 ahrefs 进行 seo 分析
  • 网站排名怎么做的百度怎么投放自己的广告
  • 代做ppt网站防城港网站seo
  • 湖南省工程建设信息官方网站高质量外链
  • 广州黄埔做网站的公司哪家好百度广告联盟平台官网
  • 天河移动网站建设线上推广费用
  • 微信网站建设合同南宁市优化网站公司
  • 网站开发可以学吗谷歌官方网站登录入口
  • 保定市城乡建设局官方网站百度地址
  • 岳阳seo外包现在学seo课程多少钱
  • 政府网站建设 需求调查通知手机搭建网站
  • 淘宝找人做网站靠谱吗国际实时新闻
  • 阿里云做网站需要些什么软件好的竞价推广外包公司