Home > Back-end >  C prime problems
C prime problems

Time:10-07

The problem is to read a set of integer vector, and calculate and output the adjacent data. If read is odd, the last number no sum, will prompt the user and outputs the value
# include & lt; Iostream>
# include & lt; Vector>
Using STD: : vector;
using namespace std;
Int main ()
{
Int s;
int i;
Vector The text;
While (cin> S)
{
The text. The push_back (s);
}
I=the text. The size ();
If (I % 2==0)
{
For (vector : : size_type a=0; a{
cout}
}
The else
{
cout<" The last element no sum, value is: "& lt; }
return 0;
}

Compile time appear the error:
The error C2296: '-' : illegal, left operand has the type 'unsigned int (__thiscall STD: : vector : : *) (void) const. '
Pray god give directions

CodePudding user response:

For (vector : : size_type a=0; aInstead of
For (vector : : size_type a=0; a

While I for odd number, no execution sum operation, the text [I] subscript overrun

CodePudding user response:

Thank you, run successfully
  • Related