私は、ユーザーが数値を入力できるようにする独自の非常に単純なプログラムを作成しています。現時点では、コードは問題なく機能しますが、ifelseステートメントの検証が必要です。これは私が現在持っているものです。
#include <iostream>
#include <string>
using namespace std;
int main()
{
unsigned __int64 input = 0;
char str[] = "qwertyuiopasdfghjklzxcvbnm[]{};'#:@~,./<>?|!£$%^&*()";
cout << "Insert a number" << endl;
cin >> input;
if (input % 2 == 0)
{
cout << "Even!" << endl;
}
else
{
if (input% 2 == 1)
{
cout << "Odd" << endl;
cout << "Lets make it even shall we? " << "Your new number is... " << input + 1 << endl;
}
else if (isdigit(str[0]))
{
cout << "That isn't a number!" << endl;
}
}
system("pause");
return 0;
}
私が抱えている問題は、ユーザーが数値以外のものを入力した場合、返される値は「偶数」であるということです。
私はあなたたちと女の子が助けることができることを願っています!ジョン