I am confused with the input and output, can anyone tell me why I get such output.
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
int ival, oddcnt(0), evencnt(0);
while (cin >> ival) {
switch (ival) {
case 1, 3, 5, 7, 9:
oddcnt++;
break;
case 2, 4, 6, 8, 10:
evencnt++;
break;
}
}
cout << "Quantity of odd number:" << oddcnt << "\n"
<< "Quantity of even number:" << evencnt << endl;
system("pause");
return 0;
}
This is the result I get:
Input:1 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 6 6 6 7 7 7 7 8 8 9 9 10 10 10
EOF
Output:Quantity of odd number:2
Quantity of even number:3