File tree 1 file changed +11
-48
lines changed
1 file changed +11
-48
lines changed Original file line number Diff line number Diff line change @@ -32,54 +32,17 @@ _hs_s_a_tst
32
32
如果没有一个字符能被打出,则输出空行。
33
33
重要的事情要说三遍!!
34
34
35
+ #include < cctype>
35
36
#include < iostream>
36
37
using namespace std ;
37
38
int main () {
38
- string a, b;
39
- getline (cin, a);// 为了防止第一行是空的,不能用cin >> a,用getline(cin, a)
40
- getline (cin, b);
41
- if (a.length () == 0 ) {
42
- cout << b;
43
- return 0 ;
44
- }
45
- int flag = 0 ;
46
- int lena = a.length ();
47
- int lenb = b.length ();
48
- // 检验是否有大写
49
- for (int i = 0 ; i < lena; i++) {
50
- if (a[i] == ' +' ) {
51
- flag = 1 ;
52
- a[i] = ' #' ;
53
- }
54
- }
55
- // 去除大写字母
56
- if (flag) {
57
- for (int i = 0 ; i < lenb; i++) {
58
- if (b[i] >= ' A' && b[i] <= ' Z' ) {
59
- b[i] = ' #' ;
60
- }
61
- }
62
- }
63
- // 去除其它字母
64
- for (int i = 0 ; i < lenb; i++) {
65
- for (int j = 0 ; j < lena; j++) {
66
- if (a[j] == b[i]) {
67
- b[i] = ' #' ;
68
- }
69
- if (a[j] >= ' A' && a[j] <= ' Z' && b[i] == a[j] + 32 ) {
70
- b[i] = ' #' ;
71
- }
72
- }
73
- }
74
- int flag1 = 0 ;
75
- // print
76
- for (int i = 0 ; i < lenb; i++) {
77
- if (b[i] != ' #' ) {
78
- cout << b[i];
79
- flag1 = 1 ;
80
- }
81
- }
82
- if (flag1 == 0 )
83
- cout << endl;
84
- return 0 ;
85
- }
39
+ string bad, should;
40
+ getline (cin, bad); // 为了防止第一行是空的,不能用cin >> ,用getline(cin, ...)
41
+ getline (cin, should);
42
+ for (int i = 0 , length = should.length (); i < length; i++) {
43
+ if (bad.find (toupper (should[i])) != string::npos) continue ;
44
+ if (isupper (should[i]) && bad.find (' +' ) != string::npos) continue ;
45
+ cout << should[i];
46
+ }
47
+ return 0 ;
48
+ }
You can’t perform that action at this time.
0 commit comments