diff --git a/src/case.py b/src/case.py deleted file mode 100644 index 2748531f65c9c8ac9bd4b9fe4ca8cc13bdae5b84..0000000000000000000000000000000000000000 --- a/src/case.py +++ /dev/null @@ -1,47 +0,0 @@ -# 示例文件 -# 来自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 diff --git a/src/java/build_java_template.py b/src/java/build_java_template.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2748531f65c9c8ac9bd4b9fe4ca8cc13bdae5b84 100644 --- a/src/java/build_java_template.py +++ b/src/java/build_java_template.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