C++ vector add integer value

Description

C++ vector add integer value

#include <iostream>
#include <iomanip>
#include <vector>

int main()//from   w  ww  .j ava  2  s .  com
{
  std::vector<int> values;
  // Add element values 1 to 100
  for (int i {1}; i <= 100; ++i)
    values.push_back(i);

  int count {};                              // Number of output values
  int perline {8};                           // Number output perline

  for (auto value : values){
    if ((value % 7) == 0 || (value % 13) == 0)
       continue;
    std::cout << std::setw(5) << value;
    if ((++count % perline) == 0)
       std::cout << "\n";
  }
  std::cout << std::endl;
}



PreviousNext

Related