以下のプログラムを実行すると、何回入力する必要がありますか?あなたはabout while(!(cin >> x))
cin >> number;
そして数を読んで、どちらも
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