From 53cc56e02d3b5060f36aaeec78e4e6007057bd61 Mon Sep 17 00:00:00 2001 From: Sticki Date: Mon, 29 Aug 2022 21:03:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0gitignore=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=A8=A1=E6=9D=BF=E7=94=9F=E6=88=90=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/case.py | 47 ++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .gitignore create mode 100644 src/case.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..993aa5d --- /dev/null +++ b/.gitignore @@ -0,0 +1,84 @@ +### Java ### +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Python ### +/.settings/ +/bin/ +__pycache__/ +/venv/ + +### filter databfile、sln file ### +*.mdb +*.ldb +*.sln + +### class file ### +*.pyc +*.com +*.class +*.dll +*.exe +*.o +*.so + +### compression file ### +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip +*.via +*.tmp +*.err +*.log +*.ini +*.jpg +*.png +*.ico +### OS generated files ### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db +/.mvn/ +/mvnw.cmd +/mvnw diff --git a/src/case.py b/src/case.py new file mode 100644 index 0000000..2748531 --- /dev/null +++ b/src/case.py @@ -0,0 +1,47 @@ +# 示例文件 +# 来自CSDN博客 +# OJ平台代码模板自动生成 +# https://blog.csdn.net/qq_44193969/article/details/126290082 + +def is_float_num(str): + s = str.split('.') + if len(s) > 2: + return False + else: + for si in s: + if not si.isdigit(): + return False + return True + + +def is_number(i): + try: + int(i) + return True + except: + return False + + +def parse_input_one(item, var_name, input_var_idx=0, assgin_var_type=None): + var_type = None + var_def = None + var_input = None + + if assgin_var_type is not None: + var_type = assgin_var_type + var_def_ = f"{assgin_var_type} {var_name} = str_{input_var_idx}" + else: + if is_number(item): + var_type = "int" + var_def_ = f"int {var_name} = Integer.parseInt(str_{input_var_idx})" + elif is_float_num(item): + var_type = "float" + var_def_ = f"float {var_name} = Float.parseFloat(str_{input_var_idx})" + else: + var_type = "String" + var_def_ = f"String {var_name} = str_{input_var_idx}" + + var_def = f"{var_type} {var_name}" + input_template = f"String str_{input_var_idx} = scan.nextLine().trim();" + var_input = f"{input_template}\n\t\t{var_def_}" + return var_type, var_name, var_def, var_input -- GitLab