c++ primer plus 6.7

2023-07-08 10:52:15 浏览数 (1)

6.7 not.cpp

代码语言:javascript复制
#include <stdio.h>
#include <iostream>
#include <climits> 
using namespace std;
bool isint(double num);
bool isint(double num){
	if(num<=INT_MAX&&num>=INT_MIN)return true;
	else return false;
	
	//return 1;
}
int main(void) {
	double num;
	cout<<"you dude!enter an integer value"<<endl;
	cin>>num;
	while(!isint(num)){
		cout<<"out of range-- please try again!"<<endl;
		cin>>num;
	}
	int val=int(num);
	cout<<"you enter the integer"<<val<<endl;
	
    return 0;
}

0 人点赞