-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1033.c
More file actions
79 lines (69 loc) · 1.76 KB
/
1033.c
File metadata and controls
79 lines (69 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
1033 旧键盘打字 (20 分)
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?
输入格式:
输入在 2 行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过 10
5
个字符的串。可用的字符包括字母 [a-z, A-Z]、数字 0-9、以及下划线 _(代表空格)、,、.、-、+(代表上档键)。题目保证第 2 行输入的文字串非空。
注意:如果上档键坏掉了,那么大写的英文字母无法被打出。
输出格式:
在一行中输出能够被打出的结果文字。如果没有一个字符能被打出,则输出空行。
*/
//无难点
#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
char b[100050];
gets(a);
gets(b);
int na = strlen(a);
int nb = strlen(b);
int flag = 0;
int count = 0;
for(int i = 0; i < na; i++)
{
if(a[i] == '+')
{
flag = 1;
continue;
}
else if(a[i] >= 'A' && a[i] <= 'Z')
for(int j = 0; j < nb; j++)
{
if(b[j] == a[i] || b[j] == a[i] + 32)//坏键用*替换
{
b[j] = '*';
count++;
}
else
continue;
}
else if(a[i] == ',' || a[i] == '.' || a[i] == '-' || a[i] == '_' || (a[i] >= '0' && a[i] <= '9'))
for(int j = 0; j < nb; j++)
{
if(b[j] == a[i])
{
b[j] = '*';
count++;
}
else
continue;
}
}
if(flag == 1)
for(int i = 0; i < nb; i++)
if(b[i] >= 'A' && b[i] <= 'Z' )
{
b[i] = '*';
count++;
}
if(count == nb)
printf("\n");
else
for(int i = 0; i < nb; i++)
if(b[i] != '*')
printf("%c", b[i]);
return 0;
}