2014年8月5日 星期二

邏輯判斷範例

上一篇寫了有關於邏輯方面的程式,但是並沒有寫出一個介紹,所以我就把我練習的程式po上來讓大家參考。
-------------------------------------------------------------------------------------
#include <iostream>
#include <cctype)
using namespace std;
int main()
{
              char ch;
              int alpha;
              int blank;
             cout << "輸入任一個字元,我便能辨別他:"<<endl;
             cin.get(ch);                         //接收到的字元符號
             while(ch!='a')                         //給while迴圈一個辨別的\依據

              {
                         if(isalpha(ch))
                          {
                                    cout<<"you get the alpha!!!!";
                                             break;
                           }
                           else if(isblank(ch))
                           {
                                    cout<<"you get the blank";
                                            break;
                             }
                             else 
                                           break;
                  }

                  return 0;

}
----------------------------------------------------------------------------------
上面是個簡單的寫法,可以使用各種不同的方法嘗試,當然也可以用C語言來試試看。





                           

沒有留言:

張貼留言