板凳——————————————————c++(62)

#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iterator>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

    // INSERT_ELEMENTS (collection, first, last)
    // - fill values from first to last into the collection
    // - NOTE: NO half-open range
    template <typename T>
    inline void INSERT_ELEMENTS (T& coll, int first, int last)
    {
        for (int i=first; i<=last; ++i) {
        coll.insert(coll.end(),i);
        }
    }

    // PRINT_ELEMENTS()
    // - prints optional string optcstr followed by
    // - all elements of the collection coll
    // - separated by spaces
    template <typename T>
    inline void PRINT_ELEMENTS (const T& coll,
                            const std::string& optcstr="")
    {
        std::cout << optcstr;
        for (auto elem : coll) {
        std::cout << elem << ' ';
        }
        std::cout << std::endl;
    }

    // PRINT_MAPPED_ELEMENTS()
    // - prints optional string optcstr followed by
    // - all elements of the key/value collection coll
    // - separated by spaces
    template <typename T>
    inline void PRINT_MAPPED_ELEMENTS (const T& coll,
                                   const std::string& optcstr="")
    {
        std::cout << optcstr;
        for (auto elem : coll) {
        std::cout << '[' << elem.first
                  << ',' << elem.second << "] ";
        }
        std::cout << std::endl;
    }
// The c++ standard libary 2nd p535    
    bool checkEven (int elem, bool even)
    {
        if (even) {
        return elem % 2 == 0;
        }
        else {
        return elem % 2 == 1;
        }
    }
// The c++ standard libary 2nd p541    
    bool doubled (int elem1, int elem2)
    {
       return elem1 * 2 == elem2;
    }
    
// The c++ standard libary 2nd p543    
    bool bothEvenOrOdd (int elem1, int elem2)
    {
        return elem1 % 2 == elem2 % 2;
    }
    
    int main()
    {
       std::deque<int> coll;

       coll = { 1, 2, 7, 7, 6, 3, 9, 5, 7, 7, 7, 3, 6 };
       PRINT_ELEMENTS(coll);

       // find three consecutive elements with value 7
       std::deque<int>::iterator pos;
       pos = std::search_n (coll.begin(), coll.end(),    // range
                   3,                           // count
                   7);                          // value

       // print result
       if (pos != coll.end()) {
           std::cout << "three consecutive elements with value 7 "
            << "start with " << distance(coll.begin(),pos) +1
            << ". element" << std::endl;
       }
       else {
           std::cout << "no four consecutive elements with value 7 found"
            << std::endl;
       }

       // find four consecutive odd elements
       pos = std::search_n (coll.begin(), coll.end(),    // range
                   4,                           // count
                   0,                           // value
                   [](int elem, int value){     // criterion
                       return elem%2==1;
                   });

       // print result
       if (pos != coll.end()) {
           std::cout << "first four consecutive odd elements are: ";
           for (int i=0; i<4; ++i, ++pos) {
            std::cout << *pos << ' ';
           }
       }
       else {
           std::cout << "no four consecutive elements with value > 3 found";
       }
       std::cout << std::endl;
// The c++ standard libary 2nd p534
        std::deque<int> coll2;
        std::list<int> subcoll;

        INSERT_ELEMENTS(coll2,1,7);
        INSERT_ELEMENTS(coll2,1,7);
        INSERT_ELEMENTS(subcoll,3,6);

        PRINT_ELEMENTS(coll2,   "coll2:    ");
        PRINT_ELEMENTS(subcoll, "subcoll: ");

        // search first occurrence of subcoll in coll
        std::deque<int>::iterator pos2;
        pos2 = std::search (coll2.begin(), coll2.end(),         // range
                  subcoll.begin(), subcoll.end());  // subrange

        // loop while subcoll found as subrange of coll
        while (pos2 != coll2.end()) {
        // print position of first element
        std::cout << "subcoll found starting with element "
             << std::distance(coll2.begin(), pos2) + 1
             << std::endl;  //error coll.begin()   subcoll found starting with element 34831
                                                        // subcoll found starting with element 34838

        // search next occurrence of subcoll
        ++pos2;          
        pos2 = std::search (pos2, coll2.end(),                  // range
                     //error pos,       造成死循环  2020年06月19日 20时05分42秒
                      subcoll.begin(), subcoll.end());  // subrange
        }
// The c++ standard libary 2nd p535
        std::vector<int> coll3;

        INSERT_ELEMENTS(coll3, 1, 9);
        PRINT_ELEMENTS(coll3, "coll3: ");

        // arguments for checkEven()
        // - check for: "even odd even"
        bool checkEvenArgs[3] = { true, false, true };

        // search first subrange in coll
        std::vector<int>::iterator pos3;
        pos3 = std::search (coll3.begin(), coll3.end(),       // range
                  checkEvenArgs, checkEvenArgs+3, // subrange values
                  checkEven);                     // subrange criterion

        // loop while subrange found
        while (pos3 != coll3.end()) {
        // print position of first element
        std::cout << "subrange found starting with element "
             << std::distance(coll3.begin(),pos3) + 1
             << std::endl;

        // search next subrange in coll
        pos3 = std::search (++pos3, coll3.end(),              // range
                      checkEvenArgs, checkEvenArgs+3, // subr. values
                      checkEven);                     // subr. criterion
        }
// The c++ standard libary 2nd p539        
        std::deque<int> coll4;
        std::list<int> subcoll2;

        INSERT_ELEMENTS(coll4,1,7);
        INSERT_ELEMENTS(coll4,1,7);

        INSERT_ELEMENTS(subcoll2,3,6);

        PRINT_ELEMENTS(coll4,   "coll4:    ");
        PRINT_ELEMENTS(subcoll2,"subcoll2: ");

        // search last occurrence of subcoll in coll
        std::deque<int>::iterator pos4;
        pos4 = std::find_end (coll4.begin(), coll4.end(),         // range
                    subcoll2.begin(), subcoll2.end());  // subrange

        // loop while subcoll found as subrange of coll
        std::deque<int>::iterator end(coll4.end());
        while (pos4 != end) {
        // print position of first element
        std::cout << "subcoll found starting with element "
             << std::distance(coll4.begin(),pos4) + 1
             << std::endl;

        // search next occurrence of subcoll
        end = pos4;
        pos4 = std::find_end (coll4.begin(), end,               // range
                        subcoll2.begin(), subcoll2.end()); // subrange
        }
// The c++ standard libary 2nd p540        
        std::vector<int> coll5;
        std::list<int> searchcoll;

        INSERT_ELEMENTS(coll5,1,11);
        INSERT_ELEMENTS(searchcoll,3,5);

        PRINT_ELEMENTS(coll5,      "coll5:       ");
        PRINT_ELEMENTS(searchcoll,"searchcoll: ");

        // search first occurrence of an element of searchcoll in coll
        std::vector<int>::iterator pos5;
        pos5 = std::find_first_of (coll5.begin(), coll5.end(),     // range
                         searchcoll.begin(),   // beginning of search set
                         searchcoll.end());    // end of search set
        std::cout << "first element of searchcoll in coll5 is element "
         << std::distance(coll5.begin(),pos5) + 1
         << std::endl;

        // search last occurrence of an element of searchcoll in coll
        std::vector<int>::reverse_iterator rpos2;
        rpos2 = std::find_first_of (coll5.rbegin(), coll5.rend(),  // range
                          searchcoll.begin(),  // beginning of search set
                          searchcoll.end());   // end of search set
        std::cout << "last element of searchcoll in coll5 is element "
         << std::distance(coll5.begin(),rpos2.base())
         << std::endl;
// The c++ standard libary 2nd p541    
        std::vector<int> coll6;

       coll6.push_back(1);
       coll6.push_back(3);
       coll6.push_back(2);
       coll6.push_back(4);
       coll6.push_back(5);
       coll6.push_back(5);
       coll6.push_back(0);

       PRINT_ELEMENTS(coll6,"coll6: ");

       // search first two elements with equal value
       std::vector<int>::iterator pos6;
       pos6 = std::adjacent_find (coll6.begin(), coll6.end());

       if (pos6 != coll6.end()) {
           std::cout << "first two elements with equal value have position "
            << std::distance(coll6.begin(),pos6) + 1
            << std::endl;
       }

       // search first two elements for which the second has double the value of the first
       pos6 = std::adjacent_find (coll6.begin(), coll6.end(),   // range
                        doubled);                   // criterion

       if (pos6 != coll6.end()) {
           std::cout << "first two elements with second value twice the "
            << "first have pos. "
            << std::distance(coll6.begin(),pos6) + 1
            << std::endl;
       }
       
// The c++ standard libary 2nd p543
           std::vector<int> coll7;
        std::list<int> coll8;

        INSERT_ELEMENTS(coll7,1,7);
        INSERT_ELEMENTS(coll8,3,9);

        PRINT_ELEMENTS(coll7,"coll7: ");
        PRINT_ELEMENTS(coll8,"coll8: ");

        // check whether both collections are equal
        if (std::equal (coll7.begin(), coll7.end(),  // first range
               coll8.begin())) {            // second range
        std::cout << "coll7 == coll8" << std::endl;
        }
        else {
        std::cout << "coll7 != coll8" << std::endl;
        }

        // check for corresponding even and odd elements
        if (std::equal (coll7.begin(), coll7.end(),  // first range
               coll8.begin(),               // second range
               bothEvenOrOdd)) {            // comparison criterion
        std::cout << "even and odd elements correspond" << std::endl;
        }
        else {
        std::cout << "even and odd elements do not correspond" << std::endl;
        }    
// The c++ standard libary 2nd p545        
        std::vector<int> coll11;
        std::list<int> coll12;
        std::deque<int> coll13;

        coll11 = { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        coll12 = { 1, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
        coll13 = { 11, 12, 13, 19, 18, 17, 16, 15, 14, 11 };

        PRINT_ELEMENTS(coll11,"coll11: ");
        PRINT_ELEMENTS(coll12,"coll12: ");
        PRINT_ELEMENTS(coll13,"coll13: ");

        // check whether both collections have equal elements in any order
        if (std::is_permutation (coll11.cbegin(), coll11.cend(), // first range
                        coll12.cbegin())) {            // second range
        std::cout << "coll11 and coll12 have equal elements" << std::endl;
        }
        else {
        std::cout << "coll11 and coll12 don't have equal elements" << std::endl;
        }

        // check for corresponding number of even and odd elements
        if (std::is_permutation (coll11.cbegin(), coll11.cend(), // first range
                        coll13.cbegin(),               // second range
                        bothEvenOrOdd)) {             // comparison criterion
        std::cout << "numbers of even and odd elements match" << std::endl;
        }
        else {
        std::cout << "numbers of even and odd elements don't match" << std::endl;
        }   
    }
/*
wannian07@wannian07-PC:~$ g++ -std=c++17 -o c13 c13.cpp
wannian07@wannian07-PC:~$ ./c13
1 2 7 7 6 3 9 5 7 7 7 3 6
three consecutive elements with value 7 start with 9. element
first four consecutive odd elements are: 3 9 5 7

coll2:    1 2 3 4 5 6 7 1 2 3 4 5 6 7
subcoll: 3 4 5 6
subcoll found starting with element 3
subcoll found starting with element 10

coll3: 1 2 3 4 5 6 7 8 9
subrange found starting with element 2
subrange found starting with element 4
subrange found starting with element 6

coll4:    1 2 3 4 5 6 7 1 2 3 4 5 6 7
subcoll2: 3 4 5 6
subcoll found starting with element 10
subcoll found starting with element 3

coll5:       1 2 3 4 5 6 7 8 9 10 11
searchcoll: 3 4 5
first element of searchcoll in coll5 is element 3
last element of searchcoll in coll5 is element 5

coll6: 1 3 2 4 5 5 0
first two elements with equal value have position 5
first two elements with second value twice the first have pos. 3

coll7: 1 2 3 4 5 6 7
coll8: 3 4 5 6 7 8 9
coll7 != coll8
even and odd elements correspond

coll11: 1 1 2 3 4 5 6 7 8 9
coll12: 1 9 8 7 6 5 4 3 2 1
coll13: 11 12 13 19 18 17 16 15 14 11
coll11 and coll12 have equal elements
numbers of even and odd elements match

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
牙科就诊管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了用户在线查看数据。管理员管理病例管理、字典管理、公告管理、药单管理、药品管理、药品收藏管理、药品评价管理、药品订单管理、牙医管理、牙医收藏管理、牙医评价管理、牙医挂号管理、用户管理、管理员管理等功能。牙科就诊管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 管理员在后台主要管理病例管理、字典管理、公告管理、药单管理、药品管理、药品收藏管理、药品评价管理、药品订单管理、牙医管理、牙医收藏管理、牙医评价管理、牙医挂号管理、用户管理、管理员管理等。 牙医列表页面,此页面提供给管理员的功能有:查看牙医、新增牙医、修改牙医、删除牙医等。公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。药品管理页面,此页面提供给管理员的功能有:新增药品,修改药品,删除药品。药品类型管理页面,此页面提供给管理员的功能有:新增药品类型,修改药品类型,删除药品类型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值