int main(void) { int i,N; int Login(int i,struct AccountInfo *Input,struct AccountInfo *T); int RFind(int i,struct AccountInfo *Input,struct AccountInfo *T); struct AccountInfo *RInsert(int i,struct AccountInfo *Input, struct AccountInfo *T); struct AccountInfo *T; T=NULL; if(freopen(Filename,"r",stdin)==NULL) exit(0); scanf("%d",&N); struct AccountInfo *Input=(struct AccountInfo *)malloc(sizeof(struct AccountInfo)*N); for(i=0;i<N;i++) scanf("%c %l64d %s",&Input[i].choice,&Input[i].Account,Input[i].Password); //Input for(i=0;i<N;i++) { if(Input[i].choice=='L') if(Login(i,Input,T)==0)printf("ERROR: Account Not Exist\n"); else if(Login(i,Input,T)==1)printf("Log in Successful\n"); else if(Login(i,Input,T)==-1)printf("ERROR: Wrong Password\n"); if(Input[i].choice=='R') if(RFind(i,Input,T)==1)printf("ERROR: Account Number Already Exists\n"); else if(RFind(i,Input,T)==0) {RInsert(i,Input,T); printf("Register Successful\n");} } system("pause"); }
int RFind(int i,struct AccountInfo *Input,struct AccountInfo *T) { if(T==NULL) return 0; //Register Successful if(Input[i].Account<T->Account) RFind(i,Input,T->Left); else if(Input[i].Account>T->Account) RFind(i,Input,T->Right); else return 1; //ERROR: Account Number Already Exists }
int32_t nsTString_CharT::RFind( const char* aString, bool aIgnoreCase, int32_t aOffset, int32_t aCount) const { return RFind(nsDependentCString(aString), aIgnoreCase, aOffset, aCount); }
int32_t nsACString::RFind(const char_type *aStr, ComparatorFunc c) const { return RFind(aStr, strlen(aStr), c); }
void test_rfind (charT, Traits*, Allocator*, const StringFunc &func, const StringTestCase &tcase) { typedef std::basic_string <charT, Traits, Allocator> String; static const std::size_t BUFSIZE = 256; static charT wstr_buf [BUFSIZE]; static charT warg_buf [BUFSIZE]; std::size_t str_len = sizeof wstr_buf / sizeof *wstr_buf; std::size_t arg_len = sizeof warg_buf / sizeof *warg_buf; charT* wstr = rw_expand (wstr_buf, tcase.str, tcase.str_len, &str_len); charT* warg = rw_expand (warg_buf, tcase.arg, tcase.arg_len, &arg_len); // construct the string object and the argument string const String s_str (wstr, str_len); const String s_arg (warg, arg_len); if (wstr != wstr_buf) delete[] wstr; if (warg != warg_buf) delete[] warg; wstr = 0; warg = 0; // save the state of the string object before the call // to detect wxception safety violations (changes to // the state of the object after an exception) const StringState str_state (rw_get_string_state (s_str)); const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str (); const String& arg_str = tcase.arg ? s_arg : s_str; const charT arg_val = make_char (char (tcase.val), (charT*)0); std::size_t size = tcase.size >= 0 ? tcase.size : s_arg.max_size () + 1; #ifndef _RWSTD_NO_EXCEPTIONS // is some exception expected ? const char* expected = 0; if (1 == tcase.bthrow) expected = exceptions [2]; const char* caught = 0; #else // if defined (_RWSTD_NO_EXCEPTIONS) if (tcase.bthrow) return; #endif // _RWSTD_NO_EXCEPTIONS try { std::size_t res = 0; switch (func.which_) { case RFind (cptr): res = s_str.rfind (arg_ptr); break; case RFind (cstr): res = s_str.rfind (arg_str); break; case RFind (cptr_size): res = s_str.rfind (arg_ptr, tcase.off); break; case RFind (cptr_size_size): res = s_str.rfind (arg_ptr, tcase.off, size); break; case RFind (cstr_size): res = s_str.rfind (arg_str, tcase.off); break; case RFind (val): res = s_str.rfind (arg_val); break; case RFind (val_size): res = s_str.rfind (arg_val, tcase.off); break; default: RW_ASSERT ("test logic error: unknown rfind overload"); return; } const std::size_t exp_res = NPOS != tcase.nres ? tcase.nres : String::npos; // verify the returned value rw_assert (exp_res == res, 0, tcase.line, "line %d. %{$FUNCALL} == %{?}%zu%{;}%{?}npos%{;}, " "got %{?}%zu%{;}%{?}npos%{;}", __LINE__, NPOS != tcase.nres, exp_res, NPOS == tcase.nres, String::npos != res, res, String::npos == res); } #ifndef _RWSTD_NO_EXCEPTIONS catch (const std::exception &ex) { caught = exceptions [4]; rw_assert (0, 0, tcase.line, "line %d. %{$FUNCALL} %{?}expected %s,%{:}" "unexpectedly%{;} caught std::%s(%#s)", __LINE__, 0 != expected, expected, caught, ex.what ()); } catch (...) { caught = exceptions [0]; rw_assert (0, 0, tcase.line, "line %d. %{$FUNCALL} %{?}expected %s,%{:}" "unexpectedly%{;} caught %s", __LINE__, 0 != expected, expected, caught); } #endif // _RWSTD_NO_EXCEPTIONS if (caught) { // verify that an exception thrown during allocation // didn't cause a change in the state of the object str_state.assert_equal (rw_get_string_state (s_str), __LINE__, tcase.line, caught); } else if (-1 != tcase.bthrow) { rw_assert (caught == expected, 0, tcase.line, "line %d. %{$FUNCALL} %{?}expected %s, caught %s" "%{:}unexpectedly caught %s%{;}", __LINE__, 0 != expected, expected, caught, caught); } }
PRInt32 nsString::RFind( const PRUnichar* aString, PRInt32 aOffset, PRInt32 aCount ) const { return RFind(nsDependentString(aString), aOffset, aCount); }
int32_t nsString::RFind( const char16_t* aString, int32_t aOffset, int32_t aCount ) const { return RFind(nsDependentString(aString), aOffset, aCount); }