1. 程式人生 > 其它 >6.2.3 邏輯NOT操作符:!

6.2.3 邏輯NOT操作符:!

技術標籤:C++ Primer PlusNOT邏輯操作符邏輯表示式C++C++ Primer Plus

程式清單6.7 not.cpp

#include <iostream>
#include <climits>

bool is_int(double);

int main()
{
    using namespace std;

    double num;

    cout << "Yo, dude! Enter an integer value:";
    cin >> num;

    while (
!is_int(num)) { cout << "Out of range -- please try again:"; cin >> num; } int val = int(num); cout << "You've entered the integer " << val << "\nBye\n"; return 0; } bool is_int(double x) { if (x <=
INT_MAX && x >= INT_MIN) return true; else return false; }

在這裡插入圖片描述
在這裡插入圖片描述

待解決問題:
  1. 輸入12.3,輸出12?