當我運行下面的程序時,爲什麼我必須輸入兩次數字?about while(!(cin >> x))
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int x;
int number;
cout << "Please enter a integer ." << endl;
cin >> number;
while (!(cin>>x))
{
cout << "Invalid value !" << endl;
system("pause");
return 0;
}
cout << "Your number is " << number << " ." << endl
爲什麼你有x和整數作爲變量? x ???的目的是什麼? – Raindrop7