练习洛谷遗落的知识点

本文详细介绍了编程中的一些基础知识,包括开根号的函数、海伦公式、C++的sort函数、输入字符的方法、字符串比较函数、fmax函数、string与int的转换、memset函数用于清空字符串、快速排序函数qsort的使用以及strtok和substr函数的应用。这些内容涵盖了数据结构和算法的重要知识点,对于学习和提升编程能力非常有帮助。

练习洛谷遗落的知识点(刷C语言编程) (qq.com)

1、开根号的函数:

#include "math.h"

double x=sqrt(a)

或者

double x=pow(a,1/2);//计算a^(1/2)

2、海伦公式:

海伦公式的表达式为S=√p(p-a)(p-b)(p-c),其中S表示三角形的面积,p是半周长,即p=(a+b+c)/2,其中a,b,c为三角形的边长。

注意:

(1)、留意其范围使用的是int 还是long 还是long long 还是float后者double。

(2)、注意输出格式是小数点后几位数

(3)、当输出数据有几个时注意其输出的顺序。

3、C++语言sort函数

sort()函数是基于快速排序实现的,sort()函数可以将一个容器或者数组的值进行排序,还可以自定义排序方

<think> 我们正在检查给定的plist文件是否有遗漏的内容。根据提供的plist文件和引用内容,我们重点需要关注以下几个方面: 1. **ATS(App Transport Security)配置**:根据引用[1]和[3],我们配置了`NSAllowsArbitraryLoads`为`true`,但这在生产环境中并不安全。苹果推荐的做法是使用`NSExceptionDomains`来指定允许的域名,而不是完全禁用ATS。因此,我们需要考虑是否应该添加例外域名。 2. **隐私权限描述**:如果应用使用了相机、位置、麦克风等权限,必须在plist中添加相应的权限描述键(如`NSCameraUsageDescription`),否则提交到App Store会被拒绝。当前plist中没有这些权限描述。 3. **CodePush部署密钥**:根据引用[3],如果使用CodePush,需要在plist中添加`CodePushDeploymentKey`。当前plist中未配置。 4. **其他可能的安全配置**:引用[4]提到可以使用证书固定(SSL Pinning)来增强安全性,但这通常在代码中配置,而不是在plist中。 5. **键值对格式问题**:在之前的回答中已经修正了拼写错误和格式问题,但需要确认当前plist是否已经修正。 6. **Flutter相关配置**:根据之前的建议,我们删除了`UIMainStoryboardFile`,因为Flutter项目不需要。 7. **网络权限**:除了ATS,还需要确保有网络权限。在iOS中,默认允许网络访问,但如果需要后台网络访问,则需要另外配置。 8. **其他常用配置**:如后台模式、推送通知等,根据应用的实际功能可能需要添加。 ### 检查当前plist的遗漏内容 1. **ATS安全配置**(重要): 当前配置: ```xml <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> ``` 建议修改为(如果确实需要允许任意加载,则保留,但最好替换为例外域名): ```xml <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>example.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict> ``` 2. **隐私权限描述**(根据应用功能添加): 例如,如果使用相机: ```xml <key>NSCameraUsageDescription</key> <string>需要相机权限来拍照</string> ``` 3. **CodePush部署密钥**(如果使用CodePush): ```xml <key>CodePushDeploymentKey</key> <string>你的部署密钥</string> ``` 4. **后台模式**(如果需要后台运行): 例如,后台位置更新: ```xml <key>UIBackgroundModes</key> <array> <string>location</string> </array> ``` 5. **推送通知**(如果需要): ```xml <key>FirebaseAppDelegateProxyEnabled</key> <false/> ``` 6. **启动屏幕(Launch Screen)**:当前配置了`UILaunchStoryboardName`为`LaunchScreen`,但需要确保在Xcode项目中存在对应的故事板文件。 ### 修正后的完整plist建议 以下是一个修正后的示例,包含了上述提到的可能遗漏点(请根据实际需求选择添加): ```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <!-- ATS配置:建议使用例外域名 --> <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>yourdomain.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict> <!-- 基本配置 --> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleDisplayName</key> <string>Newdemo</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>newdemo</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>$(FLUTTER_BUILD_NAME)</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>$(FLUTTER_BUILD_NUMBER)</string> <key>LSRequiresIPhoneOS</key> <true/> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <!-- 方向支持 --> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <!-- 状态栏 --> <key>UIViewControllerBasedStatusBarAppearance</key> <false/> <!-- 性能相关 --> <key>CADisableMinimumFrameDurationOnPhone</key> <true/> <key>UIApplicationSupportsIndirectInputEvents</key> <true/> <!-- 隐私权限描述(示例) --> <key>NSLocationWhenInUseUsageDescription</key> <string>需要位置权限来提供附近的服务</string> <key>NSCameraUsageDescription</key> <string>需要相机权限来拍照</string> <!-- 后台模式(示例) --> <key>UIBackgroundModes</key> <array> <!-- <string>audio</string> --> <!-- <string>location</string> --> </array> <!-- CodePush(如果使用) --> <!-- <key>CodePushDeploymentKey</key> --> <!-- <string>YOUR_KEY_HERE</string> --> </dict> </plist> ``` ### 总结遗漏内容 1. **ATS安全配置不完善**:使用`NSAllowsArbitraryLoads`为`true`虽然方便,但存在安全风险,建议改为按域名配置例外[^1][^3]。 2. **隐私权限描述缺失**:根据应用使用的功能,需要添加相应的权限描述字符串[^2]。 3. **CodePush部署密钥**:如果使用CodePush热更新,需要添加部署密钥[^3]。 4. **后台模式**:如果应用需要后台运行(如播放音频、位置更新等),需要添加`UIBackgroundModes`键。 5. **推送通知**:如果使用推送通知,需要添加相关配置(如`FirebaseAppDelegateProxyEnabled`)。 ### 检查步骤建议 1. 确认应用使用的敏感权限(相机、位置、麦克风等),并添加对应的使用描述。 2. 如果使用http连接,将ATS配置改为例外域名方式。 3. 根据应用功能,添加后台模式、推送通知等配置。 4. 如果使用CodePush,添加部署密钥。 请根据实际应用功能,补充上述遗漏的配置项。 §§ 相关问题 §§ 1. 如何在 iOS 的 plist 中配置隐私权限描述(如相机、位置)? 2. Flutter 项目中如何自定义 iOS 启动画面(Launch Screen)? 3. 如何为 iOS 应用配置后台模式? 4. 如何为 Flutter 应用配置 CodePush? </think> 根据您提供的 plist 配置文件和参考内容,以下是详细的检查结果和建议: ### ✅ 已正确配置的项目 1. **ATS 安全配置** ```xml <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> ``` - 已正确禁用 ATS 限制(允许 HTTP 请求),这对开发环境和混合内容场景是必要的[^1][^3] - 但生产环境应考虑更安全的域名白名单方式(见建议) 2. **基本应用信息** ```xml <key>CFBundleDisplayName</key><string>Newdemo</string> <key>CFBundleName</key><string>newdemo</string> <key>CFBundleVersion</key><string>$(FLUTTER_BUILD_NUMBER)</string> ``` - 应用名称/版本号配置正确,使用了 Flutter 的变量注入 3. **方向控制** ```xml <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> ``` - 方向控制完整,支持竖屏和横屏 --- ### ⚠️ 需要补充的关键配置 1. **隐私权限描述(必须添加)** 缺少权限使用说明,提交 App Store 会被拒绝: ```xml <!-- 示例:相机权限 --> <key>NSCameraUsageDescription</key> <string>需要访问相机用于拍摄照片</string> <!-- 示例:位置权限 --> <key>NSLocationWhenInUseUsageDescription</key> <string>需要位置信息提供附近服务</string> ``` *根据实际功能添加:麦克风(NSMicrophoneUsageDescription)、相册(NSPhotoLibraryUsageDescription)等[^2]* 2. **ATS 安全优化(建议)** ```xml <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>yourdomain.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict> ``` - 生产环境应避免 `NSAllowsArbitraryLoads`,改用域名白名单更安全[^1][^4] 3. **后台模式(按需添加)** ```xml <key>UIBackgroundModes</key> <array> <string>audio</string> <!-- 后台播放 --> <string>location</string> <!-- 后台定位 --> </array> ``` 4. **推送通知(如果使用)** ```xml <key>FirebaseAppDelegateProxyEnabled</key> <false/> <!-- 如果使用Firebase --> ``` 5. **CodePush 密钥(如果使用热更新)** ```xml <key>CodePushDeploymentKey</key> <string>YOUR_IOS_DEPLOYMENT_KEY</string> <!-- 引用[3] --> ``` --- ### 🔍 其他注意事项 1. **Flutter 特定优化** - 删除 `UIMainStoryboardFile`(Flutter 不需要 Main 故事板) - 确保 `LaunchScreen.storyboard` 文件存在 2. **网络权限验证** 虽然 ATS 允许 HTTP,但需确保 App Sandbox 已启用网络: ```xml <key>com.apple.security.network.client</key> <true/> ``` 3. **安全加固建议** - 对于敏感 API 密钥,避免直接写在 plist 中(如 Fabric 统计 key)[^2] - 考虑实现证书锁定(SSL Pinning)增强安全性[^4] > **验证命令**:在终端执行 `plutil -lint Info.plist` 检查语法完整性
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值