-2
我很新的C++,我不知道我怎么会输出一个8整数输入第5的整数?以下是我迄今为止:如何从8整数长输入输出第5个整数?然后告诉我们,如果第5整数是奇数还是偶数?C++
using namespace std;
void main()
{
int SID, i, x ;
cout << "Pleas enter 8 digits :";
cin >> SID;
cout << "The 5th digit is : " << x << endl;
for (SID = i; i < 10; i++);
if (x % 2 = 0) { cout << "It is even number."; }
else { cout << "It is odd number."; }
正如你可以看到我想要使用x作为第5的整数,但我不知道如何代码。我知道使用模数除法将决定第5个整数是偶数还是奇数。我知道在这里使用循环是强制性的,并决定使用for循环,但我觉得我没有正确输入它。
提示:'for'循环无助于你。尝试将'cin >> SID'放入循环中。 – owacoder