Ideas:
1. All of the input first character string stored up until the read #;
2. Analyzing the character string one by one, and accordingly output.
note:
1. The number of password is correct and did not want to end the program exceeds the limit;
2. behind colon spaces;
3. If the password is wrong and has reached the limit must first enter the number of output Wrong password: the user enters the wrong password, and then outputs Account locked.
Attach AC Code:
. 1 #include <the iostream>
2 #include <The iomanip>
. 3 #include <cstdio>
. 4 the using namespace STD;
. 5
. 6 String STR [ 1000 ]; // to keep the string entered
. 7
. 8 int main () {
. 9 String S ;
10 int n-, CNT = 0 ;
. 11 CIN >> S;
12 is CIN >> n-;
13 is . CIN GET (); // read out carriage
14 the while ( . 1 ) {
15 String T;
16 getline (CIN, T);
. 17 STR [CNT ++] = T;
18 is IF (T == " # " ) BREAK ; // read # ends
. 19 }
20 is for ( int I = 0 ; I < the CNT- . 1 ; I ++) { // cycle # up to the front end of a string
21 is IF (STR [I] == S) {
22 is COUT << " available for purchase in " << endl; // correct password and end
23 is BREAK ;
24 }
25 the else COUT << " Wrong password: " << STR [I] << endl;
26 is IF (I == N- . 1 ) { // If the limit number of times arrives at the input, output and Account locked ends
27 COUT << " the Account Locked " ;
28 BREAK ;
29 }
30 }
31 is return 0 ;
32 }
ACM white, there are many inadequacies, please correct me.