cmake_minimum_required(VERSION 3.15)project(Tutorial VERSION 1.0)add_library(tutorial_compiler_flags INTERFACE)target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11)set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")target_compile_options(tutorial_compiler_flags INTERFACE "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>""$<${msvc_cxx}:$<BUILD_INTERFACE:-W3>>")configure_file(TutorialConfig.h.in TutorialConfig.h)add_subdirectory(MathFunctions)add_executable(Tutorial tutorial.cxx)target_link_libraries(Tutorial PUBLIC MathFunctions tutorial_compiler_flags)target_include_directories(Tutorial PUBLIC
"${PROJECT_BINARY_DIR}")
MathFunctions/CMakeList.txt
#createthe MathFunctions libraryadd_library(MathFunctions MathFunctions.cxx)#statethat anybody linking to us needs to include the current source dir#tofind MathFunctions.h,while we don't.target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})#shouldwe use our own math functionsoption(USE_MYMATH "Use tutorial provided math implementation" ON)if(USE_MYMATH)target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")#librarythat just does sqrtadd_library(SqrtLibrary STATICmysqrt.cxx
)#linkSqrtLibrary to tutorial_compiler_flagstarget_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)target_link_libraries(MathFunctions PRIVATE SqrtLibrary)endif()#linkMathFunctions to tutorial_compiler_flagstarget_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
第一题:小美的平衡矩阵
注意in.nextLine()和in.next()
import java.util.Scanner;public class Main {static final int maxn 210;public static void main(String[] args) {Scanner in new Scanner(System.in);int n in.nextInt();char[][] a new char[maxn]…