Advertisement
heranchris0430

字串比對

Mar 20th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. // ConsoleApplication1.cpp : 定義主控台應用程式的進入點。
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     while (1) {
  13.         string a = { "" }, b = { "" };
  14.         int n[2] = { 0 };
  15.  
  16.         cout << "輸入二個字串";
  17.         cin >> a >> b;
  18.  
  19.         n[0] = size(a);
  20.         n[1] = size(b);
  21.  
  22.         if (n[0] == n[1])
  23.             cout << "YES" <<endl;
  24.  
  25.         if (n[0] != n[1])
  26.             cout << "NO" <<endl;
  27.  
  28.         system("PAUSE");
  29.         system("CLS");
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement