Java教程

shell脚本实例之判断输入年份判断是否为闰年

本文主要是介绍shell脚本实例之判断输入年份判断是否为闰年,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

read -p “请输入一个年份:” year

if [ “KaTeX parse error: Expected EOF, got # at position 49: …份" exit fi #̲使用正则测试变量 year 中…year” =~ [a?Z] ]];then echo “你输入的不是数字” exit fi

判断是否为闰年

if [ $[year % 4] -eq 0 ] && [ [ y e a r e c h o " [year % 100] -ne 0 ];then echo " [yearecho"year年是闰年" elif [ [ y e a r e c h o " [year % 400] -eq 0 ];then echo " [yearecho"year年是闰年" else e

这篇关于shell脚本实例之判断输入年份判断是否为闰年的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!