1061. Dating (20)-PAT

通过寻找字符串中共同出现的大写字母和特定位置的小写字母来解析隐藏的日期和时间。该方法利用了特定字符在字符串中的位置,将它们转换为星期几、小时和分钟。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter 'D', representing the 4th day in a week; the second common character is the 5th capital letter 'E', representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is 's' at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.


Input Specification:


Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.


Output Specification:


For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT" for Saturday, and "SUN" for Sunday. It is guaranteed that the result is unique for each case.


Sample Input:
3485djDkxh4hhGE 
2984akDfkkkkggEdsb 
s&hgsfdk 
d&Hyscvnm
Sample Output:

THU 14:04

推荐指数:

来源:http://pat.zju.edu.cn/contests/pat-a-practise/1061

注意题目的意思。

week 大写字母的A-G

hh 0-9 A-N

mm 位置

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

const int N=80;
char w[7][4]={{"MON"},{"TUE"},{"WED"},{"THU"},{"FRI"},{"SAT"},{"SUN"}};
int main()
{
	char s1[N],s2[N],s3[N],s4[N];
	scanf("%s%s%s%s",s1,s2,s3,s4);
	int i=0;
	int week,hh,mm;
	while(i<strlen(s1)&&i<strlen(s2)){
		if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G'){
			week=s1[i]-'A';
			break;
		}
		i++;
	}
	i++;
	while(i<strlen(s1)&&i<strlen(s2)){
		if(s1[i]==s2[i]&& ((s1[i]>='A'&&s1[i]<='N')||(s1[i]>='0'&&s1[i]<='9'))){
			if((s1[i]>='A'&&s1[i]<='N'))
				hh=s1[i]-'A'+10;
			else if(s1[i]>='0'&&s1[i]<='9')
				hh=s1[i]-'0';
			break;
		}
		i++;
	}
	i=0;
	while(i<strlen(s3)&&i<strlen(s4)){
		if(s3[i]==s4[i]&&((s3[i]>='A'&&s3[i]<='Z')||(s3[i]>='a'&&s3[i]<='z'))){
			mm=i;
			break;
		}
		i++;
	}
	printf("%s %02d:%02d\n",w[week],hh,mm);
	return 0;
}


<think>好的,用户遇到了一个构建错误,提示在AndroidManifest.xml的第46行,provider标签的authorities属性包含无效字符'$'。我需要仔细分析这个问题,并给出解决方案。 首先,用户提供的错误信息显示,aapt.exe在处理资源时发现authorities属性有非法字符'$'。根据Android的文档,authorities属性必须是一个有效的Content Provider标识符,通常由包名和字符串组成,不能包含特殊字符,比如'$'。 查看用户之前的对话历史,用户一直在调整AndroidManifest.xml以兼容旧版的build-tools 23.0.3和android-23。在最后一次回复中,我提供的兼容版本里,provider的authorities属性使用了"${applicationId}.fileProvider"。问题可能出在这里,因为在旧版本的构建工具中,可能不支持使用${applicationId}这样的变量,或者需要正确的转义。 接下来,我需要验证这个假设。在旧版的Android构建工具中,${applicationId}通常是在构建过程中由Gradle替换的变量。但如果用户直接使用aapt命令行工具进行构建,而没有正确替换这个变量,那么aapt会直接使用这个字符串,导致出现非法字符,因为实际生成APK时applicationId可能未被正确解析,导致authorities属性中包含未替换的'$'符号。 解决方案是将authorities属性的值替换为具体的包名,而不是使用${applicationId}变量。例如,如果应用的包名是com.dw.Dating.lua,那么应该将authorities设置为"com.dw.Dating.lua.fileProvider"。这样就能避免使用变量,确保构建工具正确识别。 另外,用户可能还在使用旧版的Support Library,需要确认FileProvider的类名是否正确。例如,旧版本的Support Library可能使用android.support.v4.content.FileProvider,而用户是否正确引用了该类。 同时,检查用户提供的AndroidManifest.xml中的provider标签是否正确闭合,是否有其他语法错误。例如,是否遗漏了引号或标签闭合符号。 此外,用户可能在res/xml/file_paths_fanwei.xml中配置了错误的路径,虽然这个问题可能不会导致当前的错误,但需要确认该文件是否存在以及内容是否正确。 总结问题,用户需要将authorities属性中的${applicationId}替换为实际的包名,确保没有特殊字符,从而解决非法字符错误。同时,检查其他可能的配置问题,如FileProvider的类名和路径配置。</think>以下是修复 **`authorities` 属性包含非法字符 '$'** 的解决方案: --- ### 🔧 **问题定位** 在 `AndroidManifest.xml` 中: ```xml <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileProvider" <!-- ❌ 包含非法字符 '$' --> android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths_fanwei" /> </provider> ``` **错误原因**: 旧版 `aapt` 工具(build-tools 23.0.3)**不支持 `${applicationId}` 变量插值**,直接将其视为非法字符 `$`。 --- ### ✅ **解决方案** #### 方法 1:手动指定固定包名(推荐) 将 `android:authorities` 的值替换为实际包名: ```xml <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.dw.Dating.lua.fileProvider" <!-- ✅ 使用固定包名 --> android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths_fanwei" /> </provider> ``` #### 方法 2:升级构建工具(长期方案) 升级到新版 build-tools(如 28.0.3)和 Gradle: ```gradle android { buildToolsVersion "28.0.3" } ``` 新版工具链支持 `${applicationId}` 插值,但需要同步升级 `targetSdkVersion` 至 28+。 --- ### 📦 **配套修复** #### 1. **确认 `FileProvider` 类路径正确** 确保使用的是 **Support Library v4**: ```xml android:name="android.support.v4.content.FileProvider" ``` #### 2. **检查 `file_paths_fanwei.xml`** 确保文件存在且内容合法(res/xml/file_paths_fanwei.xml): ```xml <?xml version="1.0" encoding="utf-8"?> <paths> <external-path name="hotfix" path="." /> </paths> ``` #### 3. **清理冗余配置** 移除不兼容的 `maxSdkVersion`(旧版工具可能无法识别): ```xml <!-- 删除以下属性 --> android:maxSdkVersion="28" ``` --- ### 🧪 **最终验证步骤** 1. **清理项目缓存** 删除 `Temp/` 和 `Library/` 目录后重新导入资源。 2. **强制重新生成 Manifest** 在 Unity 中导出 Android 项目时,确保勾选 "Write Permission" 和 "Write Owner Project"。 3. **使用 aapt 验证 Manifest** 在命令行运行: ```bash aapt dump badging AndroidManifest.xml ``` 确认无语法错误。 --- ### 📌 **注意事项** - **包名一致性**:确保 `package="com.dw.Dating.lua"` 与 `authorities="com.dw.Dating.lua.fileProvider"` 的包名完全一致。 - **Unity 版本兼容性**:Unity 2019 LTS 及以下版本需手动维护 AndroidManifest.xml,建议升级到 Unity 2020.3 LTS 或更高版本。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值