#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
char a1[100],a2[100];
int aa[40]={0};
int temp=0;
char b;
scanf("%s%s",a1,a2);
for(unsigned int i=0;i<strlen(a2);i++){
if(a2[i]>='0'&&a2[i]<='9'){
temp=a2[i]-'0';
aa[temp]++;
}
else if(a2[i]>='A'&&a2[i]<='Z'){
temp=a2[i]-'A'+10;
aa[temp]++;
}
else if(a2[i]>='a'&&a2[i]<='z'){
temp=a2[i]-'a'+10;
aa[temp]++;
}
else if(a2[i]=='_'){
aa[39]++;
}
else{
continue;
}
}
for(unsigned int i=0;i<strlen(a1);i++){
if(a1[i]>='0'&&a1[i]<='9'){
temp=a1[i]-'0';
}
else if(a1[i]>='A'&&a1[i]<='Z'){
temp=a1[i]-'A'+10;
}
else if(a1[i]>='a'&&a1[i]<='z'){
temp=a1[i]-'a'+10;
}
else if(a1[i]=='_'){
temp=39;
}
else{
continue;
}
if(aa[temp]==0){
aa[temp]++;
if(temp<10){
b=temp+'0';
cout<<b;
}
else if(temp>10&&temp<39){
b=temp-10+'A';
cout<<b;
}
else if(temp==39){
cout<<'_';
}
}
}
}
1029 旧键盘 pat 测试点四通不过,求原因
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- qzjhjxj 2023-04-28 15:48关注
第54行: else if(temp>10&&temp<39){ 应修改为: else if(temp>=10&&temp<39){
供参考:#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { char a1[100], a2[100]; int aa[40] = { 0 }; int temp = 0; char b; scanf("%s%s", a1, a2); for (unsigned int i = 0; i < strlen(a2); i++) { if (a2[i] >= '0' && a2[i] <= '9') { temp = a2[i] - '0'; aa[temp]++; } else if (a2[i] >= 'A' && a2[i] <= 'Z') { temp = a2[i] - 'A' + 10; aa[temp]++; } else if (a2[i] >= 'a' && a2[i] <= 'z') { temp = a2[i] - 'a' + 10; aa[temp]++; } else if (a2[i] == '_') { aa[39]++; } else { continue; } } for (unsigned int i = 0; i < strlen(a1); i++) { if (a1[i] >= '0' && a1[i] <= '9') { temp = a1[i] - '0'; } else if (a1[i] >= 'A' && a1[i] <= 'Z') { temp = a1[i] - 'A' + 10; } else if (a1[i] >= 'a' && a1[i] <= 'z') { temp = a1[i] - 'a' + 10; } else if (a1[i] == '_') { temp = 39; } else { continue; } if (aa[temp] == 0) { aa[temp]++; if (temp < 10) { b = temp + '0'; cout << b; } else if (temp >= 10 && temp < 39) { //else if (temp > 10 && temp < 39) 修改 b = temp - 10 + 'A'; cout << b; } else if (temp == 39) { cout << '_'; } } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥20 非root手机,如何精准控制手机流量消耗的大小,如20M
- ¥15 远程安装一下vasp
- ¥15 自己做的代码上传图片时,报错
- ¥15 Lingo线性规划模型怎么搭建
- ¥15 关于#python#的问题,请各位专家解答!区间型正向化
- ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
- ¥50 comsol温度场仿真无法模拟微米级激光光斑
- ¥15 上传图片时提交的存储类型
- ¥15 VB.NET如何绘制倾斜的椭圆
- ¥15 arbotix没有/cmd_vel话题