Vla_DOS

Untitled

Jan 23rd, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <string.h>
  4. #include<sstream>
  5. #include <ctype.h>
  6. #include<cctype>
  7. #include<list>
  8.  
  9. using namespace std;
  10.  
  11. ////////////////////////////////////////////////////////////////////////////////////////
  12. //  Constances
  13. ////////////////////////////////////////////////////////////////////////////////////////
  14.  
  15. #define N_PRODUCT 2
  16.  
  17. struct Brand_t {
  18.     int Model_Num;
  19.     string Product_Name;
  20.     list<string> Colors;
  21. } brands[2];
  22.  
  23. ////////////////////////////////////////////////////////////////////////////////////////
  24. //  Functions
  25. ////////////////////////////////////////////////////////////////////////////////////////
  26. using namespace std;
  27.  
  28. int main()
  29. {
  30.     string mystr;
  31.     int n;
  32.  
  33.     for (n = 0; n < N_PRODUCT; n++)
  34.     {
  35.         cout << "Enter Model Number: ";
  36.         brands[n].Model_Num = 1 + n;
  37.         cout << "Enter Product Name: ";
  38.         brands[n].Product_Name = "qw";
  39.         list<string>::iterator it;
  40.         brands->Colors.push_back("Red");
  41.         brands->Colors.push_back("Yellow");
  42.         brands->Colors.push_back("Blue");
  43.     }
  44.  
  45.  
  46.     for (n = 0; n < N_PRODUCT; n++)
  47.     {
  48.         std::list<string>::iterator findIter = std::find(brands->Colors.begin(), brands->Colors.end(), "Blue");
  49.  
  50.         if (brands->Colors.end() == findIter)
  51.         {
  52.             std::cout << "item not found" << std::endl;
  53.         }
  54.         else
  55.         {
  56.             const int pos = std::distance(brands->Colors.begin(), findIter) + 1;
  57.             std::cout << "item divisible by 17 found at position " << pos << std::endl;
  58.         }
  59.     }
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment