wendy890711

帳號密碼確認

Apr 14th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void main()
  6. {
  7. int count=0;
  8. char account[] = "0076C048";
  9. char password[] = "123456";
  10.  
  11. char a[50], p[50];
  12. while (count < 3)
  13. {
  14. cout << "請輸入帳號" << endl;
  15. cin >> a;
  16. cout << "請輸入密碼" << endl;
  17. cin >> p;
  18.  
  19. int samea = strcmp(account, a);
  20. int samep = strcmp(password, p);
  21.  
  22. if (samea == 0 && samep == 0)
  23. {
  24. cout << "帳號正確" << endl;
  25. cout << "密碼正確" << endl;
  26. cout << "登錄中..." << endl;
  27. break;
  28. }
  29. else if(samea==0&&samep!=0)
  30. {
  31. cout << "帳號正確" << endl;
  32. cout << "密碼錯誤" << endl;
  33. count++;
  34. }
  35. else if (samea != 0 && samep == 0)
  36. {
  37. cout << "帳號錯誤" << endl;
  38. cout << "密碼正確" << endl;
  39. count++;
  40. }
  41. else
  42. {
  43. cout << "帳號錯誤" << endl;
  44. cout << "密碼錯誤" << endl;
  45. count++;
  46. }
  47. }
  48. if(count==3)
  49. cout << "你是豬嗎?" << endl;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment